private void FiltrarDados(string texto, int id = 0) { try { string sCampo = Grade.BuscarCampo(ref dgvDados, cbCampos.Text); var filtro = new AgendamentoFiltroViewModel(); filtro.DataInicial = txtDataInicial.txtData.Text; filtro.DataFinal = txtDataFinal.txtData.Text; filtro.IdUsuario = ursFiltroUsuario.RetornarSelecao(); filtro.IdCliente = ursFiltroCliente.RetornarSelecao(); filtro.IdTipo = ursFiltroTipo.RetornarSelecao(); filtro.IdStatus = ursFiltroStatus.RetornarSelecao(); if (id > 0) { sCampo = "Age_Id"; texto = id.ToString(); //filtro.Campo = "Bas_Id"; //filtro.Texto = id.ToString(); } _listaConsulta = _agendamentoApp.Filtrar(filtro, sCampo, texto, Funcoes.IdUsuario, cbPesquisa.SelectedIndex == 0).ToList(); dgvDados.DataSource = _listaConsulta; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public IEnumerable <AgendamentoConsultaViewModel> Filtrar([FromBody] AgendamentoFiltroViewModel filtro, string campo, string texto, int idUsuario, bool contem = true) { try { return(_servicoAgendamento.Filtrar(filtro, campo, texto, idUsuario, contem)); } catch (Exception ex) { throw new Exception(ex.Message); } }
public IEnumerable <AgendamentoConsultaViewModel> Filtrar(AgendamentoFiltroViewModel filtro, string campo, string texto, int idUsuario, bool contem = true) { return(_agendamentoRepositorioDapper.Filtrar(filtro, campo, texto, idUsuario, contem)); }
public AgendamentoConsultaViewModel[] Filtrar(AgendamentoFiltroViewModel filtro, string campo, string texto, int idUsuario, bool contem = true) { string url = Constantes.URL + "Agendamento/Filtrar?campo={0}&texto={1}&idUsuario={2}&contem={3}"; return(new Operacao <AgendamentoConsultaViewModel>().ObjetoToJSon(string.Format(url, campo, texto, idUsuario, contem), filtro)); }
public IEnumerable <AgendamentoConsultaViewModel> Filtrar(AgendamentoFiltroViewModel filtro, string campo, string texto, int idUsuario, bool contem = true) { string sTexto = ""; sTexto = "'" + texto + "%'"; if (contem) { sTexto = "'%" + texto + "%'"; } var sb = new StringBuilder(); var usuarioCliente = new UsuarioEF(); sb.AppendLine(" SELECT"); sb.AppendLine(" Age_Id as Id,"); sb.AppendLine(" Age_Data as Data,"); sb.AppendLine(" Age_Hora as Hora,"); sb.AppendLine(" Age_Cliente as ClienteId,"); sb.AppendLine(" Age_NomeCliente as NomeCliente,"); sb.AppendLine(" Tip_Nome as TipoNome,"); sb.AppendLine(" Usu_Nome as UsuarioNome,"); sb.AppendLine(" Sta_Nome as StatusNome"); sb.AppendLine(" FROM Agendamento"); sb.AppendLine(" INNER JOIN Cliente ON Age_Cliente = Cli_Id"); sb.AppendLine(" INNER JOIN Tipo ON Age_Tipo = Tip_Id"); sb.AppendLine(" INNER JOIN Usuario ON Age_Usuario = Usu_Id"); sb.AppendLine(" INNER JOIN Status ON Age_Status = Status.Sta_Id"); if (!string.IsNullOrWhiteSpace(texto)) { sb.AppendLine(" WHERE " + campo + " LIKE " + sTexto); } else { sb.AppendLine("WHERE Age_Id > 0"); } sb.AppendLine(usuarioCliente.PermissaoUsuario(idUsuario)); if ((!string.IsNullOrWhiteSpace(filtro.DataInicial)) && (filtro.DataInicial.Trim() != "/ /")) { sb.AppendLine(" AND Age_Data >=" + Funcoes.DataIngles(filtro.DataInicial)); } if ((!string.IsNullOrWhiteSpace(filtro.DataFinal)) && (filtro.DataFinal.Trim() != "/ /")) { sb.AppendLine(" AND Age_Data <=" + Funcoes.DataIngles(filtro.DataFinal)); } if (!string.IsNullOrWhiteSpace(filtro.IdCliente)) { sb.AppendLine(" AND Age_Cliente IN (" + filtro.IdCliente + ")"); } if (!string.IsNullOrWhiteSpace(filtro.IdTipo)) { sb.AppendLine(" AND Age_Tipo IN (" + filtro.IdTipo + ")"); } if (!string.IsNullOrWhiteSpace(filtro.IdStatus)) { sb.AppendLine(" AND Age_Status IN (" + filtro.IdStatus + ")"); } if (!string.IsNullOrWhiteSpace(filtro.IdUsuario)) { sb.AppendLine(" AND Age_Usuario IN (" + filtro.IdUsuario + ")"); } var lista = _repositorioConsulta.GetAll(sb.ToString()); return(lista); }