private void TFListaCartaFrete_Load(object sender, EventArgs e) { this.Icon = Utils.ResourcesUtils.TecnoAliance_ICO; //Buscar carta frete bsCartaFrete.DataSource = new CamadaDados.Frota.TCD_CartaFrete().Select( new Utils.TpBusca[] { new Utils.TpBusca() { vNM_Campo = "a.cd_empresa", vOperador = "=", vVL_Busca = "'" + Cd_empresa.Trim() + "'" }, new Utils.TpBusca() { vNM_Campo = "a.cd_motorista", vOperador = "=", vVL_Busca = "'" + Cd_motorista.Trim() + "'" }, new Utils.TpBusca() { vNM_Campo = "isnull(a.st_registro, 'A')", vOperador = "=", vVL_Busca = "'A'" }, new Utils.TpBusca() { vNM_Campo = "a.id_acerto", vOperador = "is", vVL_Busca = "null" } }, 0, string.Empty); }
public void AfterBusca() { this.Icon = Utils.ResourcesUtils.TecnoAliance_ICO; Utils.TpBusca[] filtro = new Utils.TpBusca[4]; filtro[0].vNM_Campo = "a.cd_empresa"; filtro[0].vOperador = "="; filtro[0].vVL_Busca = "'" + Cd_empresa.Trim() + "'"; filtro[1].vNM_Campo = "a.cd_motorista"; filtro[1].vOperador = "="; filtro[1].vVL_Busca = "'" + Cd_motorista.Trim() + "'"; filtro[2].vNM_Campo = "isnull(a.st_viagem, 'A')"; filtro[2].vOperador = "in"; filtro[2].vVL_Busca = "('E', 'F')"; filtro[3].vNM_Campo = string.Empty; filtro[3].vOperador = "not exists"; filtro[3].vVL_Busca = "(select 1 from tb_frt_acerto_x_viagem x " + "where x.cd_empresa = a.cd_empresa " + "and x.id_viagem = a.id_viagem)"; if (!string.IsNullOrEmpty(IdViagem.Text)) { Array.Resize(ref filtro, filtro.Length + 1); filtro[filtro.Length - 1].vNM_Campo = "a.Id_viagem"; filtro[filtro.Length - 1].vOperador = "="; filtro[filtro.Length - 1].vVL_Busca = IdViagem.Text; } if (!string.IsNullOrEmpty(DsViagem.Text)) { Array.Resize(ref filtro, filtro.Length + 1); filtro[filtro.Length - 1].vNM_Campo = "a.DS_viagem"; filtro[filtro.Length - 1].vOperador = "="; filtro[filtro.Length - 1].vVL_Busca = DsViagem.Text; } if (!string.IsNullOrEmpty(Placa.Text.Replace("-", "").Trim())) { Array.Resize(ref filtro, filtro.Length + 1); filtro[filtro.Length - 1].vNM_Campo = "REPLACE(c.placa, '-', '')"; filtro[filtro.Length - 1].vOperador = "="; filtro[filtro.Length - 1].vVL_Busca = "'" + Placa.Text.Replace("-", string.Empty).Trim() + "'"; } if (dt_ini.Text.Trim() != "/ /") { Array.Resize(ref filtro, filtro.Length + 1); filtro[filtro.Length - 1].vNM_Campo = "convert(datetime, floor(convert(decimal(30,10), a.dt_viagem" + ")))"; filtro[filtro.Length - 1].vOperador = ">="; filtro[filtro.Length - 1].vVL_Busca = "'" + DateTime.Parse(dt_ini.Text).ToString("yyyyMMdd") + "'"; } if (dt_fin.Text.Trim() != "/ /") { Array.Resize(ref filtro, filtro.Length + 1); filtro[filtro.Length - 1].vNM_Campo = "convert(datetime, floor(convert(decimal(30,10), a.dt_viagem" + ")))"; filtro[filtro.Length - 1].vOperador = "<="; filtro[filtro.Length - 1].vVL_Busca = "'" + DateTime.Parse(dt_fin.Text).ToString("yyyyMMdd") + "'"; } bsViagem.DataSource = new CamadaDados.Frota.TCD_Viagem().Select(filtro, 0, string.Empty); }