Sou programador em Clipper a muitos anos e agora estou desenvolvendo o meu primeiro projeto em HMG. Estou achando o máximo mas ainda estou deparando com alguns problemas que não me deixam ir à frente.
Estou desenvolvendo um controle para monitorar o número de entrevistas que são realizadas no call center e estes valores devem ser atualizados online, ou pelo menos se não for possível online que se possa se recalcular os valores de tempos em tempos e/ou através de um botão.
Os valores da primeira vez eu já consegui colocar na tela, mas não estou conseguindo fazer o refresh destes valores, ou seja, não estou conseguindo executar o programa que reconta os valores das entrevistas feitas.
Em Clipper eu já possuo este controle e funciona bem, mas no formulário do HMG eu não sei como fazer.
Se alguém tiver uma idéia melhor do que esta que estou a fazer eu agradeço.
Segue abaixo o código:
Código: Selecionar todos
#include <hmg.ch>
Function Main()
DEFINE WINDOW Form_1 ;
ROW 0 ;
COL 0 ;
WIDTH 800 ;
HEIGHT 600 ;
TITLE "Controle de Estudos";
WINDOWTYPE MAIN;
ON RELEASE CloseTables();
NOMAXIMIZE ;
NOSIZE
DEFINE LABEL Label_1
ROW 20
COL 300
WIDTH 200
HEIGHT 24
VALUE "Controle de Estudos"
FONTNAME "Arial"
FONTSIZE 14
TOOLTIP "Controle de Estudos"
FONTBOLD .T.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
HELPID Nil
VISIBLE .T.
TRANSPARENT .F.
ACTION Nil
AUTOSIZE .F.
BACKCOLOR NIL
FONTCOLOR {255,0,0}
END LABEL
@ 500,700 BUTTON Button_1 PICTURE "button5.bmp" WIDTH 50 HEIGHT 50 ACTION Refresh()
Actualiza()
Mostra_valores(.f.)
END WINDOW
Form_1.Center
Form_1.Activate
Return
Procedure Opentables()
Use Controle
Return
Procedure CloseTables()
Close all
Return
Procedure Refresh
Actualiza()
Mostra_valores(.t.)
/* Esta parte está comentada pois dá erro
Use CONTROLE alias CONTROLE new
dbgotop()
do while .not. eof() .and. ATIVO
mLABEL1 = "LABEL_R"+strzero(recno(),2)+ "_1"
mLABEL2 = "LABEL_R"+strzero(recno(),2)+ "_2"
mLABEL3 = "LABEL_R"+strzero(recno(),2)+ "_3"
mLABEL4 = "LABEL_R"+strzero(recno(),2)+ "_4"
mLABEL5 = "LABEL_R"+strzero(recno(),2)+ "_5"
mLABEL6 = "LABEL_R"+strzero(recno(),2)+ "_6"
mLABEL7 = "LABEL_R"+strzero(recno(),2)+ "_7"
Form_1.mLABEL1.Refresh
Form_1.mLABEL2.Refresh
Form_1.mLABEL3.Refresh
Form_1.mLABEL4.Refresh
Form_1.mLABEL5.Refresh
Form_1.mLABEL6.Refresh
Form_1.mLABEL7.Refresh
skip
enddo
goto bott
mLABEL_TOT_1 = "LABEL_R"+strzero(recno(),2)+ "_TOT_1"
mLABEL_TOT_2 = "LABEL_R"+strzero(recno(),2)+ "_TOT_2"
close all
*/
Return
//**********************************************************************************//
// Procedure para mostrar os valores calculados e gravados no ficheiro CONTROLE.DBF //
//**********************************************************************************//
Procedure Mostra_valores
parameters mRefresh
if !mRefresh
// Primeira linha do cabeçalho das colunas //
@ 060,010 LABEL LCAB_L1C1;
WIDTH 90 ;
TOOLTIP "Concessionário";
VALUE 'Cliente'
@ 060,160 LABEL LCAB_L1C2;
WIDTH 90 ;
TOOLTIP "Total no Call Center";
VALUE 'Total no'
@ 060,250 LABEL LCAB_L1C3;
WIDTH 90 ;
TOOLTIP "Registos por fazer";
VALUE 'Registos'
@ 060,340 LABEL LCAB_L1C4;
WIDTH 90 ;
TOOLTIP "Registos bloqueados";
VALUE 'Registos'
@ 060,430 LABEL LCAB_L1C5;
WIDTH 90 ;
TOOLTIP "Registos disponíveis";
VALUE 'Registos'
@ 060,520 LABEL LCAB_L1C6;
WIDTH 90 ;
TOOLTIP "Entrevistas feitas";
VALUE 'Entrevistas'
@ 060,610 LABEL LCAB_L1C7;
WIDTH 90 ;
TOOLTIP "Percentual de entrevistas feitas sobre o total no Call Center";
VALUE '% de feitos/'
// Segunda linha do cabeçalho das colunas //
@ 075,160 LABEL LCAB_L2C2;
WIDTH 90 ;
TOOLTIP "Total no Call Center";
VALUE 'Call Center'
@ 075,250 LABEL LCAB_L2C3;
WIDTH 90 ;
TOOLTIP "Registos por fazer";
VALUE 'p/fazer'
@ 075,340 LABEL LCAB_L2C4;
WIDTH 90 ;
TOOLTIP "Registos Bloqueados";
VALUE 'Bloqueados'
@ 075,430 LABEL LCAB_L2C5;
WIDTH 90 ;
TOOLTIP "Registos disponíveis";
VALUE 'Disponíveis'
@ 075,520 LABEL LCAB_L2C6;
WIDTH 90 ;
TOOLTIP "Entrevistas feitas";
VALUE 'Feitas'
@ 075,610 LABEL LCAB_L2C7;
WIDTH 90 ;
TOOLTIP "Percentual de entrevistas feitas sobre o total no Call Center";
VALUE 'Total'
endif
mLINHA = 100
Use CONTROLE alias CONTROLE new
DbGotop()
Do While .not. eof() .and. ATIVO
mLABEL1 = "LABEL_R"+strzero(recno(),2)+ "_1"
mLABEL2 = "LABEL_R"+strzero(recno(),2)+ "_2"
mLABEL3 = "LABEL_R"+strzero(recno(),2)+ "_3"
mLABEL4 = "LABEL_R"+strzero(recno(),2)+ "_4"
mLABEL5 = "LABEL_R"+strzero(recno(),2)+ "_5"
mLABEL6 = "LABEL_R"+strzero(recno(),2)+ "_6"
mLABEL7 = "LABEL_R"+strzero(recno(),2)+ "_7"
@ mLINHA,010 LABEL &mLABEL1;
WIDTH 90 ;
TOOLTIP "Concessionário";
VALUE Controle->Estudo
@ mLINHA,170 LABEL &mLABEL2;
WIDTH 50 ;
TOOLTIP "Total no Call Center";
VALUE STR(Controle->Tot_cc,6) RIGHTALIGN
@ mLINHA,260 LABEL &mLABEL3;
WIDTH 50 ;
TOOLTIP "Registos por fazer";
VALUE STR(Controle->TOT_MENS,6) RIGHTALIGN
@ mLINHA,350 LABEL &mLABEL4;
WIDTH 50 ;
TOOLTIP "Registos bloqueados";
VALUE STR(Controle->TOT_BLOQ,6) RIGHTALIGN
skip
mLINHA += 40
Enddo
goto bott
mLABEL_TOT_1 = "LABEL_R"+strzero(recno(),2)+ "_TOT_1"
mLABEL_TOT_2 = "LABEL_R"+strzero(recno(),2)+ "_TOT_2"
mLABEL_TOT_3 = "LABEL_R"+strzero(recno(),2)+ "_TOT_3"
mLABEL_TOT_4 = "LABEL_R"+strzero(recno(),2)+ "_TOT_4"
mLABEL_TOT_5 = "LABEL_R"+strzero(recno(),2)+ "_TOT_5"
mLABEL_TOT_6 = "LABEL_R"+strzero(recno(),2)+ "_TOT_6"
mLABEL_TOT_7 = "LABEL_R"+strzero(recno(),2)+ "_TOT_7"
@ mLINHA,010 LABEL &mLABEL_TOT_1;
WIDTH 90 ;
TOOLTIP "Totais";
VALUE Controle->Estudo
@ mLINHA,170 LABEL &mLABEL_TOT_2;
WIDTH 50 ;
TOOLTIP "Total no Call Center";
VALUE STR(Controle->Tot_cc,6) RIGHTALIGN
@ mLINHA,260 LABEL &mLABEL_TOT_3;
WIDTH 50 ;
TOOLTIP "Total por fazer";
VALUE STR(Controle->Tot_mens,6) RIGHTALIGN
@ mLINHA,350 LABEL &mLABEL_TOT_4;
WIDTH 50 ;
TOOLTIP "Total de registos bloqueados";
VALUE STR(Controle->Tot_bloq,6) RIGHTALIGN
close all
Return
//************************************************************//
// Procedure para atualizar os dados do ficheiro CONTROLE.DBF //
//************************************************************//
Procedure ACTUALIZA
close all
use CONTROLE alias CONTROLE new
// abrir as areas de todos os ficheiros //
dbgotop()
do while .not. eof()
if ATIVO
mCAMINHO = alltrim(CAMINHO)
mTENTADO = alltrim(TENTADOS)
mALIAS_T = alltrim(ALIAS_TENT)
mFICH_T = mCAMINHO + mTENTADO
mGRAVADO = alltrim(GRAVADOS)
mALIAS_G = alltrim(ALIAS_GRAV)
mFICH_G = mCAMINHO + mGRAVADO
use &mFICH_T alias &mALIAS_T new SHARED
use &mFICH_G alias &mALIAS_G new SHARED
select CONTROLE
endif
skip
enddo
// Inicializa as variaveis dos totais.
mGER_CC = 0
mGER_MENS = 0
mGER_BLOQ = 0
mGER_DISP = 0
mGER_PVF = 0
mGER_PERC = 0
select CONTROLE
goto top
do while .not. eof()
if ATIVO
mALIAS_T = alltrim(ALIAS_TENT)
mALIAS_G = alltrim(ALIAS_GRAV)
mTOT_CC = 0
mTOT_MENS = 0
mTOT_BLOQ = 0
mTOT_DISP = 0
mTOT_PVF = 0
mPERCENT = 0
select &mALIAS_T
count to mTOT_MENS
count to mTOT_BLOQ for (substr(OBS1,1,2) = "XX" .or. substr(OBS1,1,2) = "xx")
mTOT_DISP = mTOT_MENS - mTOT_BLOQ
select &mALIAS_G
count to mTOT_PVF
mTOT_CC = mTOT_MENS + mTOT_PVF
mPERCENT = iif(mTOT_CC > 0, (mTOT_PVF * 100)/mTOT_CC, 0)
mGER_CC += mTOT_CC
mGER_MENS += mTOT_MENS
mGER_BLOQ += mTOT_BLOQ
mGER_DISP += mTOT_DISP
mGER_PVF += mTOT_PVF
mGER_PERC = iif(mGER_CC > 0, (mGER_PVF * 100)/mGER_CC, 0)
select CONTROLE
rlock()
replace TOT_CC with mTOT_CC
replace TOT_MENS with mTOT_MENS
replace TOT_BLOQ with mTOT_BLOQ
replace TOT_DISP with mTOT_DISP
replace TOT_PVF with mTOT_PVF
replace TOT_PERC with mPERCENT
endif
skip
enddo
goto bottom
rlock()
replace TOT_CC with mGER_CC
replace TOT_MENS with mGER_MENS
replace TOT_BLOQ with mGER_BLOQ
replace TOT_DISP with mGER_DISP
replace TOT_PVF with mGER_PVF
replace TOT_PERC with mGER_PERC
close all
Return
Agradeço desde já a ajuda.


