Local lcNome lcNome = Alltrim(this.Value) + "%" this.Parent.Grid1.RecordSource = "" && comente esta linha e veja o resultado Select i_codigo, c_nome from Dados\Nomes where Upper(c_nome) like Upper(lcNome) order by c_nome into cursor curNomes this.Parent.Grid1.RecordSource = "curNomes" && comente esta linha e veja o resultado this.Parent.Grid1.AfterRowColChange
Local lcNome, laVerif[1] *** lcNome = Alltrim(this.Parent.Parent.Text1.Value) if Empty(lcNome) && não incluir registro em branco Return EndIf *** Select i_codigo from Dados\Nomes where c_nome == lcNome into array laVerif if _tally > 0 && não incluir nome que já existe - na sua realidade provavelmente você precisará aceitar nomes iguais Return EndIf *** Begin Transaction Insert into Dados\Nomes (c_nome) values (lcNome) End Transaction this.Parent.Parent.Text1.InteractiveChange && pra refazer a busca pra que o nome excluído não apareça no cursor
DO while Txnlevel() > 0 RollBack && enquanto houver uma transação pendente executará rollback EndDo MessageBox("Ocorreu um problema que impossibilitou a execução desta operação", 16, "Excessão")
Local lcTexto if (!Used("curNomes")) or (Empty(thisform.Codigo)) Return EndIf *** lcTexto = "Confirma a execlusão de " + Alltrim(curNomes.c_nome) if MessageBox(lcTexto, 4+32, "Confirmação") = 6 Begin Transaction Delete From Dados\Nomes where i_codigo = thisform.Codigo End Transaction this.Parent.Parent.Text1.InteractiveChange && pra refazer a busca pra que o nome excluído não apareça no cursor EndIf
DO while Txnlevel() > 0 RollBack && enquanto houver uma transação pendente executará rollback EndDo MessageBox("Ocorreu um problema que impossibilitou a execução desta operação", 16, "Excessão")
thisform.Codigo = curNomes.I_Codigo this.SetAll("DynamicBackColor", "IIF(thisform.Codigo = curNomes.I_Codigo, RGB(0,0,128), RGB(255,255,255))","Column") this.SetAll("DynamicForeColor" , "IIF(thisform.Codigo = curNomes.I_Codigo, RGB(255,255,255), RGB(0,0,0))","Column") this.Refresh
function MkKey(tkKeyCtr) * Walney, esta é uma das melhores técnicas pra criar código incremental local lkKeyCtr, laCtr[1], lcDel lcDel = Set("Deleted") Set Deleted Off *** do while .t. If not Used( "KeyCtr" ) Use Dados\KeyCtr in 0 Shared Again If TxnLevel() == 0 CursorSetProp("Buffering", 1, "KeyCtr") Endif Endif m.lkKeyCtr = padr(m.tkKeyCtr, lenc(KeyCtr.kKeyCtr)) select nCtr from Dados\KeyCtr where kKeyCtr = m.lkKeyCtr into array laCtr if _tally = 0 Local lcTabNova, lcCampoNovo, aProxCod[1], lcTexto *** lcTabNova = Alltrim(Substr(tkKeyCtr, 1, At(".", tkKeyCtr) - 1)) && até o ponto lcCampoNovo = Alltrim(Substr(tkKeyCtr, At(".", tkKeyCtr) + 1)) Select Max(&lcCampoNovo) from Dados\&lcTabNova into array aProxCod aProxCod(1) = Iif(_tally = 0, 1, aProxCod(1) + 1) insert into Dados\KeyCtr (kKeyCtr, nCtr) values (m.lkKeyCtr, aProxCod(1)) loop EndIf update Dados\KeyCtr set nCtr = laCtr[1] + 1 where (kKeyCtr = m.lkKeyCtr) and (nCtr = laCtr[1]) if _tally = 0 use in KeyCtr loop endif exit enddo If Used("KeyCtr") use in KeyCtr EndIf Set Deleted &lcDel return laCtr[1] EndFunc && function MkKey( tkKeyCtr )