Meu nível é básico básico, super mega principiante.
Mas estou satisfeito com os avanços que fiz até aqui (já tinha tentado antes, sem nenhum avanço).
Seguem as telas que tenho prontas no anexo.
Código: Selecionar todos
#include "hwgui.ch"
MEMVAR cnSQL
REQUEST HB_GT_GUI_DEFAULT
FUNCTION Main
Local cRet, oSay1, oSay2, oSay3, nId, cTxt
Local oFont := HFont():Add( "MS Sans Serif",0,-13 )
private vers :="12/07/22"
private oDlg, cnSQL, us, nmus, seis
private cSair :="N"
private hrabertura :=time()
private nProvAtiv :=3
if "MPCTAC"$netname() .or. "LAPTOP-QG9OOFQ9"$netname()
nProvAtiv=18
endif
set date brit
PREPARE FONT oFont NAME "MS Sans Serif" WIDTH 0 HEIGHT -13
PREPARE FONT oFontSay NAME "MS Sans Serif" WIDTH 0 HEIGHT -13 WEIGHT 700
do while .t.
if us=NIL
cRet=login()
endif
if us#NIL
cadativ("Processos34","Processos34: iniciou",,0," ",0,0," ")
exqado("update fazendo set data='"+dtsql(date())+"',hora='"+time()+"',assunto='Iniciou o processo34' where usuario='"+us+"'",18)
endif
INIT DIALOG oDlg TITLE "Processos - Versão: "+substr(vers,7,2)+"."+substr(vers,4,2)+"."+substr(vers,1,2) AT 1, 1 SIZE 650, 600 FONT oFont
MENU OF oDlg
MENU TITLE "&Finalizar" //ACTION ConfirmarFechar()
MENUITEM "&Sair do sistema" ACTION ConfirmarFechar() //hwg_Msginfo( "Just a test", "Message" )
ENDMENU
MENU TITLE "&Consultar"
MENUITEM "&Abrir opções de consulta" ACTION consulta()
MENUITEM "&Item em execução ou próximo a executar" ACTION consproxima()
ENDMENU
MENU TITLE "C&adastrar"
MENUITEM "&Abrir opções de cadastrar" ACTION cadastro()
ENDMENU
MENU TITLE "&Manutenção"
MENUITEM "&Abrir opções de manutenção" ACTION manutencao()
ENDMENU
ENDMENU
@ 0,110 BITMAP Bitmap1 ;
SHOW "ImagemLondres.jpg" ;
STRETCH 0 ;
SIZE 650,430 //nWidth, nHeight - 65
if cRet="N" .or. cSair="S"
return .f.
elseif cRet="S"
hb_run("start PROC2P.exe " + us + " " + "visível-"+nmus + " " + seis)
@ 5,60 SAY oSAY2 CAPTION "Olá, "+alltrim(nmus)+". Escolha uma das opções clicando nos botões ou nos menus acima. As opções abrirão, por enquanto, ainda na interface tradicional, até que a mudança de interface seja completada" SIZE 590, 50
cnSQL := ConexaoMySQL()
cProc=cnSQL:Open()
cProc=cnSQL:execute("select texto from biblia where dtuso='" + Transform( DtoS( Date() ), "@R 9999-99-99" ) + "'")
if cProc:recordcount()=0
cProc=cnSQL:execute("select top 1 texto,id from biblia order by dtuso")
nId=cProc:Fields("id"):Value
cTxt=cProc:Fields("texto"):Value
cProc=cnSQL:execute("UPDATE biblia set dtuso='"+dtsql(date())+"' WHERE id="+alltrim(str(nId)))
else
cTxt=cProc:Fields("texto"):Value
endif
cnSQL:Close()
oDlg:Close()
@ 0,5 BUTTON "Finalizar (Esc)" SIZE 140,50 ON CLICK {||ConfirmarFechar()}
@ 170,5 BUTTON "Consultar" SIZE 140,50 ;
ON CLICK {||consulta()}
@ 340,5 BUTTON "Cadastrar" SIZE 140,50 ;
ON CLICK {||cadastro()}
@ 510,5 BUTTON "Manutenção" SIZE 140,50 ;
ON CLICK {||manutencao()}
@ 5,540 SAY oSAY3 CAPTION "Pensamento do dia: "+ansi(cTxt) SIZE 590, 170
endif
ACTIVATE DIALOG oDlg
if lastkey()=27
if confirmarfechar()="S"
return .f.
else
loop
endif
endif
enddo
Return
function tradicional
hb_run("\processos\processos.exe")
return
FUNCTION ConfirmarFechar()
LOCAL lConfirmado
lConfirmado := hwg_MsgYesNo("Tem certeza que deseja sair?", "Confirmação")
IF lConfirmado
cadativ("Processos34","Processos34: fechou",,0," ",0,0," ")
exqado("update fazendo set data='"+dtsql(date())+"',hora='"+time()+"',assunto='Saiu do processo34' where usuario='"+us+"'",18)
oDlg:Close()
cSair="S"
return "S"
ENDIF
RETURN "N"
function consulta
hwg_runapp("consultaprocessos34.exe "+us+" "+vers)
return
function cadastro
hb_run("cadastraprocessos34.exe "+us+" "+vers)
return
function manutencao
hb_run("manutencaoprocessos34.exe "+us+" "+vers)
return
function login
Local oFont := HFont():Add( "MS Sans Serif",0,-13 ), oTimer, oSAY1, oSAY5
Local snh := ""
Local cSenhaErrada :="N"
Local oE5, cProc
private cSair :="N"
do while .t.
if cSair="S"
return "N"
endif
INIT DIALOG oDlg TITLE "Processos - Versão: "+substr(vers,7,2)+"."+substr(vers,4,2)+"."+substr(vers,1,2) AT 150, 150 SIZE 650, 600 FONT oFont
@ 0,35 BITMAP Bitmap1 ;
SHOW "WALLPAPER.JPG" ;
STRETCH 0 ;
SIZE 650,530 //nWidth, nHeight - 65
if cSenhaErrada="S"
snh=space(20)
@ 20,50 SAY oSAY1 CAPTION "Senha errada; digite novamente a sua senha" SIZE 275, 20
endif
@ 4,10 SAY oSAY1 CAPTION "Digite a sua senha:" SIZE 120, 25
@ 135,00 GET oE5 VAR snh PASSWORD SIZE 130, 35 //Precisa do objeto GET oE5
@ 300,00 BUTTON "Entrar (Enter)" SIZE 120,35 ON CLICK {||oDlg:lResult:=.T.,hwg_EndDialog()}
@ 460,00 BUTTON "Abandonar (Esc)" SIZE 120,35 ON CLICK {||ConfirmarFechar()}
@ 480,565 BUTTON "Abrir no modo tradicional" SIZE 160,30 ON CLICK {||tradicional()}
@ 3,570 SAY oSAY2 CAPTION "O sistema está apenas começando a mudar de interface; não estranhe" SIZE 425, 20
ACTIVATE DIALOG oDlg
if lastkey()=27
if confirmarfechar()="N"
loop
endif
else
cnSQL := ConexaoMySQL()
cProc=cnSQL:Open()
cProc=cnSQL:execute("SELECT usuario,nomeusuar,baseseis FROM usuario WHERE senha='"+snh+"'")
if cProc:recordcount()=0
cProc:Close()
cnSQL:Close()
cSenhaErrada="S"
loop
else
us=cProc:Fields("usuario"):Value
nmus=cProc:Fields("nomeusuar"):Value
seis=cProc:Fields("baseseis"):Value
cnSQL:Close()
oDlg:Close()
return "S"
endif
endif
enddo
RETURN "D"
FUNCTION ConexaoMySQL(nProvedor)
LOCAL cnSQL := win_OleCreateObject("ADODB.Connection")
LOCAL cServer :="mssql.xxx.com.br"
LOCAL cDatabase :="xxx"
LOCAL cUser :="xxx"
LOCAL cPassword :="xxx"
Local cPorta :="1039"
Local cDriver :="SQL Server"
if nProvedor=3
cServer:="mysql.xxx.com.br"
cPassword="xxx"
cPorta="3306"
cDriver="MariaDB ODBC 3.1 Driver"
endif
cnSQL:ConnectionString := "DRIVER=" + cDriver +";SERVER=" + cServer + ";Database=" + cDatabase + ";UID=" + cUser + ";PWD=" + cPassword + ";PORT=" + cPorta
cnSQL:CursorLocation := 3
RETURN cnSQL
*****************************************
//=========================================================
//N|ANSI
//---------------------------------------------------------
//D|converte textos com caracteres ASCII para o padrÒo ANSI
//---------------------------------------------------------
//R|texto convertido
//=========================================================
function ANSI(cTxt) // 1 texto a ser convertido para o padrÒo ANSI
local I
local aTab
local nCod
aTab:= {;
199,252,233,226,228,224,229,231,234,235,232,239,238,236,196,197,;
201,230,198,244,246,242,251,249,255,214,220,248,163,216,215,131,;
225,237,243,250,241,209,170,176,191,174,172,189,188,161,171,187,;
35, 35, 35,124, 43,193,194,192,169, 43,124, 43, 43,162,165, 43,;
43, 43, 43, 43, 45, 43,227,195, 43, 43, 43, 43, 43, 61, 43,164,;
240,208,202,203,200,185,205,206,207, 43, 43, 35, 35,166,204, 35,;
211,223,212,210,245,213,181,254,222,218,219,217,253,221,175,180,;
173,177, 61,190,182,167,247,184,186,168,183,185,179,178, 35, 32 }
for I:= 1 to Len(cTxt)
nCod:= ASC(SubStr(cTxt,I,1))
if nCod >= 128
cTxt:= Stuff(cTxt,I,1,Chr(aTab[nCod -127]))
endif
next
return cTxt
function cadativ(ac,det,nrt,pr,cp,tu,tc,ass,usus,mc,tp)
local tela, cquery, ret
local prgor :=Hb_CmdArgArgV()
local nvz :=0
local nvz2 :=0
do case
case "vis¡vel"$nmus
prgor=prgor+"-Vis¡vel"
case "visível"$nmus
prgor=prgor+"-Visível"
case "Task"$nmus
prgor=prgor+"-Task"
case "ireto"$nmus
prgor=prgor+"-Direto"
otherwise
prgor=prgor+"-N"
endcase
prgor=prgor+"-"+hrabertura
if len(prgor)>95
prgor=substr(prgor,1,95)
endif
tu=round(tu,1)
if empty(usus) .or. valtype(usus)="U"
usus=us
endif
if empty(nrt)
nrt="-----"
endif
if empty(mc) .or. valtype(mc)="U"
mc="N"
endif
if empty(tp) .or. valtype(tp)="U" .or. tp=NIL .or. tp=nil
tp=0
endif
do while !empty(substr(det,nvz))
nvz2++
if us="I" .and. nvz2>3000 .and. int(nvz2/1000)=nvz2/1000
@ maxrow(),1 say "Acertando det no cadativ "+alltrim(str(nvz2))
inkey(.001)
endif
if nvz2>30000
exit
endif
if asc(substr(det,nvz,1))=0 .or. asc(substr(det,nvz,1))=39
if empty(substr(det,nvz))
exit
endif
det=substr(det,1,nvz-1)+substr(det,nvz+1)
else
nvz++
endif
enddo
det=alltrim(substr(det,1,2200))+"; "+procname(1)+"("+alltrim(str(procline(1)))+"); "+procname(2)+"("+alltrim(str(procline(2)))+"); "+procname(3)+"("+alltrim(str(procline(3)))+"); "+procname(4)+"("+alltrim(str(procline(4)))+"); "+procname(5)+"("+alltrim(str(procline(5)))+"); "+procname(6)+"("+alltrim(str(procline(6)))+"); "+procname(7)+"("+alltrim(str(procline(7)))+"); versÆo: "+vers+"; nProvAtiv: "+alltrim(str(nProvAtiv))
if empty(ass) .or. len(ass)=0 .or. valtype(ass)="U"
ass="-------"
endif
if len(ass)>45
ass=substr(ass,1,45)
endif
cQuery="INSERT INTO ativ (usuario,programa,data,hora,acao,detalhes,nrtarefa,prioridade,campo,tempousado,tempocompu,tempopago,assunto,maquina,marca) "+;
"values ('"+usus+"','"+prgor+"','"+dtsql(date())+"','"+time()+"','"+ac+"','"+det+"','"+nrt+"',"+alltrim(str(pr))+",'"+cp+"',"+alltrim(str(tu))+","+alltrim(str(tc))+","+alltrim(str(tp))+",'"+ass+"','"+netname()+"','"+mc+"')"
ret=exqado(cquery,nProvAtiv)
return .t.
function exqado(cQuery,nServidor)
local exq
if empty(nServidor) .or. nServidor=NIL
nServidor=3
endif
conexaoado=ConexaoMySQL(nServidor)
conexaoado:open()
exq=conexaoado:execute(cQuery)
conexaoado:Close()
return .t.
function dtsql(dt)
return Transform( DtoS( dt ), "@R 9999-99-99" )