PC SOFT

GRUPOS DE DISCUSSÃO PROFISSIONAL
WINDEVWEBDEV e WINDEV Mobile

Inicio → WINDEV 24 → FILTRO DINAMICO - FONTE NEW GROUPWARE - CADASTRO DE CLIENTES
FILTRO DINAMICO - FONTE NEW GROUPWARE - CADASTRO DE CLIENTES
Iniciado por BOLLER, ago., 10 2019 4:02 PM - Sem resposta
Membro registado
2.958 mensagems
Popularité : +89 (91 votes)
Publicado em agosto, 10 2019 - 4:02 PM
//LISTAR NA TABELA SUPERIOR DE FILTRO OS CAMPOS E AS CONDICOES DE FILTRAGEM
Procedure FillItems()

sItemList is string


// Fill the conditions
ListAdd(COL_CONDITION,"<Nenhum >" + gLink(CONDITION_EMPTY))
ListAdd(COL_CONDITION,"Contém" + gLink(CONDITION_CONTAINS))
ListAdd(COL_CONDITION,"Igual" + gLink(CONDITION_EQUAL))
ListAdd(COL_CONDITION,"Começa com" + gLink(CONDITION_STARTS_WITH))
ListAdd(COL_CONDITION,"Diferente de" + gLink(CONDITION_DIFFERENT))
ListAdd(COL_CONDITION,"Menor que" + gLink(CONDITION_GREATER))
ListAdd(COL_CONDITION,"Menor que ou igual a" + gLink(CONDITION_GREATER_EQUAL))
ListAdd(COL_CONDITION,"Menor que" + gLink(CONDITION_LESS))
ListAdd(COL_CONDITION,"Menor que ou igual a" + gLink(CONDITION_LESS_EQUAL))
ListAdd(COL_CONDITION,"Não começa com" + gLink(CONDITION_DOES_NOT_START_WITH))
ListAdd(COL_CONDITION,"Não Contém" + gLink(CONDITION_DOES_NOT_CONTAIN))

// Retrieve the list of items
sItemList = HListItem(T001_CLIENTES)

// Browse the items to add them to the table
//FOR ALL STRING sItem OF sItemList SEPAREE BY CR
// IF NOT {"T001_CLIENTES." + sItem, indItem}..Type IN (hItemBinary, hItemBinaryMemo, hItemBinaryMemo4) THEN
// if NOT MIDDLE(sItem,1,4) = "AUDT"
// TableAddLine(TABLEGRID_SELECTREC,sItem,{"T001_CLIENTES." + sItem, indItem}..Caption, CONDITION_CONTAINS)
// TABLEGRID_SELECTREC[TABLEGRID_SELECTREC].COL_CONDITION = "Contém"
// END
// END
//END

//versao antiga
FOR ALL STRING sItem OF sItemList SEPAREE by CR
IF NOT {"T001_CLIENTES." + sItem, indItem}..Type IN (hItemBinary, hItemBinaryMemo, hItemBinaryMemo4) THEN
IF NOT Middle(sItem,1,4) = "AUDT"
TableAddLine(TABLEGRID_SELECTREC,sItem,{"T001_CLIENTES." + sItem, indItem}..Caption, " ")
END
END
END



Procedure UI_FiltroDinamico()

//Filtro
sMyCondition is string
sTemporaryCondition is string
sMyItem is string

TableDeleteAll(TABLEGRID_T001_CLIENTES)




//--------------------------------atribuicao
//x is int = 0
//FOR ALL ROW OF TABLEGRID_SELECTREC
// x += 1
// if TABLEGRID_SELECTREC[x].COL_VALUEChecked = "" or TABLEGRID_SELECTREC[x].COL_VALUEChecked = " "
// TABLEGRID_SELECTREC[x].COL_CONDITION = " "
// end
//END
//TableDisplay(TABLEGRID_SELECTREC,taReExecuteQuery)
//-------------------------------------------------

// Builds the condition to apply
FOR ALL ROW OF TABLEGRID_SELECTREC
SWITCH COL_CONDITION
CASE " " // Condition: None
// No action
OTHER CASE
sMyItem = COL_ITEM
sTemporaryCondition = [" "] + "T001_CLIENTES." + sMyItem + [" "] + Replace(COL_CONDITION, "%1",COL_VALUEChecked)

IF Position(sTemporaryCondition, "%2") > 0 THEN
// The string must be built with the second value
sTemporaryCondition = Replace(sTemporaryCondition, "%2", COL_OTHERVALUE)
ELSE
IF COL_OTHERVALUE <> "" THEN
sTemporaryCondition += [" "] + COL_LINK + [" "] + COL_ITEM + [" "] + Replace(COL_CONDITION, "%1",COL_OTHERVALUE)
END
END
sMyCondition += [" AND "] + "(" + sTemporaryCondition +")"
END
END

sEmpresas = Replace(sEmpresas,";",",")

sMyCondition += [" AND "] + "(T001_CLIENTES.T001_EMPRESA IN (" + sEmpresas +")) AND (T001_CLIENTES.AUDT_Excluido = 'N')"

SQL_COD is string = [
SELECT
T001_CLIENTES.T001_ID_PESSOA ,
T001_CLIENTES.T001_EMPRESA ,
T001_CLIENTES.T001_ID_USUARIO ,
T001_CLIENTES.T001_NOME ,
T001_CLIENTES.T001_CPF ,
T001_CLIENTES.t001_Data_Nascimento ,
T001_CLIENTES.T001_SEXO ,
T001_CLIENTES.T001_NOME_MAE ,
T001_CLIENTES.T001_ESTADO_GESTAO ,
T001_CLIENTES.T001_ESTADO_INTERNO ,
T001_CLIENTES.T001_COD_CONTRATO ,
T001_CLIENTES.T001_CONTRATANTESID ,
T001_CLIENTES.T001_CONTRATANTE ,
T001_CLIENTES.T001_COD_PLANO ,
T001_CLIENTES.T001_PLANO ,
T001_CLIENTES.T001_DATA_IMPORTACAO ,
T001_CLIENTES.T001_ENVIA_RES ,
T001_CLIENTES.T001_CARTAO_NACIONAL ,
T001_CLIENTES.T001_COMPARTILHADO ,
T001_CLIENTES.T001_APELIDO ,
T001_CLIENTES.T001_DT_UTL_CONSULTA ,
T001_CLIENTES.T001_NOME_PRESTADOR_ULT ,
T001_CLIENTES.T001_PARTICULAR ,
T001_CLIENTES.T001_TERMO_CONSENTIMENTO,
T001_CLIENTES.T001_OBSERVACAOES
FROM
T001_CLIENTES,
T004_DADOS_CONTROLE
WHERE
T001_CLIENTES.T001_ID_PESSOA = T004_DADOS_CONTROLE.T001_ID_PESSOA(+) AND
]

SQL_COD += CR
SQL_COD += sMyCondition

x is 8-bytes int = 0

DS_QUERY01 is Data Source

IF HExecuteSQLQuery(DS_QUERY01,CONN_INFOTST1,hQueryDefault,SQL_COD) = True THEN
FOR EACH DS_QUERY01
x ++
TableAdd(TABLEGRID_T001_CLIENTES,DS_QUERY01.T001_ID_PESSOA +TAB+
DS_QUERY01.T001_EMPRESA +TAB+
DS_QUERY01.T001_ID_USUARIO +TAB+
DS_QUERY01.T001_NOME +TAB+
DS_QUERY01.T001_CPF +TAB+
DS_QUERY01.t001_Data_Nascimento +TAB+
DS_QUERY01.T001_SEXO +TAB+
DS_QUERY01.T001_NOME_MAE +TAB+
DS_QUERY01.T001_ESTADO_GESTAO +TAB+
DS_QUERY01.T001_ESTADO_INTERNO +TAB+
DS_QUERY01.T001_COD_CONTRATO +TAB+
DS_QUERY01.T001_CONTRATANTESID +TAB+
DS_QUERY01.T001_CONTRATANTE +TAB+
DS_QUERY01.T001_COD_PLANO +TAB+
DS_QUERY01.T001_PLANO +TAB+
DS_QUERY01.T001_DATA_IMPORTACAO +TAB+
DS_QUERY01.T001_ENVIA_RES +TAB+
DS_QUERY01.T001_CARTAO_NACIONAL +TAB+
DS_QUERY01.T001_COMPARTILHADO +TAB+
DS_QUERY01.T001_APELIDO +TAB+
DS_QUERY01.T001_DT_UTL_CONSULTA +TAB+
DS_QUERY01.T001_NOME_PRESTADOR_ULT +TAB+
DS_QUERY01.T001_PARTICULAR +TAB+
DS_QUERY01.T001_TERMO_CONSENTIMENTO+TAB+
DS_QUERY01.T001_OBSERVACAOES)


END
END

IF x = 0 THEN
ToastDisplay("Nenhum registro encontrado!")
END

TableDisplay(TABLEGRID_T001_CLIENTES, taReExecuteQuery)

EDT_NbRec = TableCount(TABLEGRID_T001_CLIENTES,toTotal)

TABLEGRID_SELECTREC..Visible = False

BTN_SEARCH2..Visible = False


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/