#include "fwce.ch"
#include "hbclass.ch"
#include "Directry.ch"
#define crlf chr(13)+chr(10)
#define CRLF chr(13)+chr(10)
#define CR chr(13)
#pragma comment (lib,"scnapi32")
FUNCTION Main()
* begin
PRIVATE oWnd
PRIVATE cLog := ""
PRIVATE nCant := 1 , oCant
PRIVATE nExist := 0
PRIVATE oInvPC , oMsg , oMarca, oPrecio , oDes , oMsg2
PRIVATE cBarCode := space(15) , oBarCode
PRIVATE files_dir := "\\caja1\c\"
* PRIVATE files_dir := "Storage Card\"
* PRIVATE files_dir := "\\notebook\c\"
PRIVATE nContador := 0 , oContador
PRIVATE cEncargado := space(15) , oEncargado
PRIVATE cCurDir := curdir()
PRIVATE lUsers := .F.
PRIVATE dFecha := date() , oFecha
PRIVATE cHora := time() , oHora
PRIVATE nNumInventario := 0 , oNumInventario // El no. de inventario es una varible o archivo en el sistema
IF StillRun("Toma-Facil++ V4.0")
Quit
ENDIF
/* Primero Pedimos la fecha y hora del sistema.
DEFINE WINDOW oWnd TITLE "Sistema de Toma de Inventario v12.15"
@ 1.0,02 SAY "Fecha :" SIZE 60, 18
@ 1.0,09 GET oFecha VAR dFecha picture "@D" SIZE 70, 20
@ 2.5,02 SAY "Hora :" SIZE 60, 18
@ 2.5,10 GET oHora VAR cHora picture "99:99:99" SIZE 70 , 20
@ 3.8,02 SAY "#-Inventario:" SIZE 75, 18
@ 3.98,11 GET oNumInventario VAR nNumInventario picture "999999" SIZE 70, 20
@ 12, 2 BUTTON "Aceptar" SIZE 80, 30 ACTION oWnd:END()
@ 12,35 BUTTON "Cerrar App" SIZE 80, 30 ACTION oWnd:END()
oWnd:Activate()
*/
* if file( files_dir+"pos\datafile\users.dbf")
* copy file (files_dir+"pos\datafile\users.dbf") to ( "users.dbf" )
* endif
* if file( "users.dbf" )
* lUsers := .T.
* use ( "users.dbf" ) alias USERS NEW
* index on upper( user_id ) to ( "users1.ntx" )
* go top
* endif
* ShowKeyboard()
DEFINE WINDOW oWnd TITLE "Toma-Facil++ V4.0"
@ 1.0,02 SAY "Cantidad :" SIZE 70, 20
@ 1.0,12 GET oCant VAR nCant picture "99999" VALID CheckCant() SIZE 40, 20
@ 2.3,02 SAY "Codigo :" SIZE 70, 20
@ 2.5,12 GET oBarCode VAR cBarcode picture "@!" VALID CheckBarCode() SIZE 120, 20
* @ 3.5,02 SAY "Encargado:" SIZE 70, 20
* @ 3.9,12 GET oEncargado VAR cEncargado picture "@!" VALID GrabaEncargado() SIZE 120, 20
@ 6.0,02 SAY oMarca VAR "Marca :" SIZE 150, 20
@ 7.3,02 SAY oPrecio VAR "Precio Venta :" SIZE 150, 20
@ 8.6,02 SAY oDes VAR "Descripcion :" SIZE 400, 20
@ 9.9,02 SAY oInvPC VAR "Inventario PC :" SIZE 150, 20
@11.2,02 SAY oMsg VAR "Ultimo Mensaje :" SIZE 400, 20
@12.7,02 SAY oMsg2 VAR "" SIZE 400, 20
@ 14.6,20 SAY oContador VAR "Contador:" SIZE 100, 20
@ 12, 2 BUTTON "Terminar" SIZE 80, 30 ACTION oWnd:END()
ACTIVATE WINDOW oWnd on Init BuildTimer( oWnd )
IF ! empty( cLog ) // Significa que hubo activad
IF file( files_dir+"download\inventa.log" )
cLog := memoread( files_dir+"download\inventa.log" ) + cLog
ENDIF
memowrit( files_dir+"download\inventa.log" , cLog )
ENDIF
* HideKeyboard()
RETURN NIL
procedure BuildTimer( oWnd , oInvPC )
* Begin
Define Timer oTimer Interval 1000 Action CheckBattery() OF oWnd
Activate Timer oTimer
return
function CheckBattery()
If BatteryLife () < 10
oMsg2:VarPut( "!! Sin bateria, favor de salir y grabar su informacion.!!")
oMsg2:refresh()
endif
return .t.
FUNCTION CheckCant()
* begin
LOCAL cFile , cRet , nActual := 0 , lReturn := .F.
IF oCant:nLastKey = 13
cBarCode := ""
cRet := SCAN_OPEN()
IF valtype( cRet ) = "C"
cRet := strtran( cRet , chr(0),"" )
FOR i := 1 TO len( cRet )
IF substr(cRet,i,1) $"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890+-/"
cBarCode += substr(cRet,i,1)
ENDIF
NEXT
ENDIF
cBarCode := alltrim(cBarcode)+space(15-len(alltrim(cBarcode)))
IF ! empty( cBarCode )
* cFile := files_dir+"download\"+alltrim(cBarcode)+strzero(nCant,4,0)+".exi"
cFile := files_dir+"download\"+alltrim(cBarcode)+".exi"
nActual := 0
cMArca:= ""
nPrecio:= 0
nDes := ""
IF file( cFile )
cTxt := memoread( cFile )
IF ! empty( cTxt )
nActual := val(substr( cTxt , 1 , 4 ))
cMarca:= substr( cTxt , 6 , 20 )
nPrecio := val( substr( cTxt , 27,7))
cDes := substr( cTxt , 35 )
oMarca:VarPut("Marca :"+cMarca )
oMarca:refresh()
oPrecio:VarPut("Precio :"+transform(nPrecio,"99,999.99"))
oPrecio:refresh()
oDes:VarPut("Descripcion :"+left(cDes,32))
oDes:refresh()
* Grabar Log
cLog += cBarcode+strzero(nCant,4,0)+strzero(nActual,4,0)+dtos(date())+time()+cEncargado + CR
memowrit( files_dir+"download\inventa.log" , cLog )
oInvPC:VarPut( "Inventario PC:"+transform( nActual ,"99999" ))
oInvPc:refresh()
IF nActual = nCant
oMsg:VarPut( "!! INVENTARIO CORRECTO, CONTINUE !!")
oCant:VarPut(1)
ELSEIF nCant > nActual // Sobrantes
oMsg:VarPut( "!! SOBRANTES, CUENTE DE NUEVO !!" )
oCant:VarPut(-999)
ELSEIF nCant < nActual // Faltantes
oMsg:VarPut( "!! FALTANTES, CUENTE DE NUEVO !!" )
oCant:VarPut(-999)
ENDIF
nContador := nContador + 1
oContador:VarPut("Contador:"+transform(nContador,"999"))
oContador:refresh()
ELSE
oMsg:VarPut( "!! ARTICULO NO EXISTE, INTENTE DE NUEVO !!" )
oCant:VarPut(1)
ENDIF
ELSE
tone(500,4)
tone(450,3)
oMsg:VarPut( "!! ARTICULO NO EXISTE, INTENTE DE NUEVO !!" )
oCant:VarPut(1)
ENDIF
oMsg:refresh()
oCant:refresh()
oBarCode:VarPut(space(15))
oBarCode:refresh()
ENDIF
ELSE
lReturn := .T.
ENDIF
RETURN lReturn
FUNCTION CheckBarCode()
* begin
LOCAL cFile , cRet , nActual := 0 , lReturn := .F. , nHandle , cTxt
IF oBarCode:nLastKey = 38
oBarCode:oJump := oCant
RETURN .T.
ENDIF
* if oBarCode:nLastKey = 13
cBarCode := alltrim(cBarcode)+space(15-len(alltrim(cBarcode)))
cFile := files_dir+"download\"+alltrim(cBarcode)+".exi"
nActual := 0
cMArca:= ""
nPrecio:= 0
nDes := ""
IF file( cFile )
cTxt := memoread( cFile )
IF ! empty( cTxt )
nActual := val(substr( cTxt , 1 , 4 ))
cMarca:= substr( cTxt , 6 , 20 )
nPrecio := val( substr( cTxt , 27,7))
cDes := substr( cTxt , 35 )
oMarca:VarPut("Marca :"+cMarca )
oMarca:refresh()
oPrecio:VarPut("Precio :"+transform(nPrecio,"99,999.99"))
oPrecio:refresh()
oDes:VarPut("Descripcion :"+left(cDes,32))
oDes:refresh()
oInvPC:VarPut( "Inventario PC:"+transform( nActual ,"99999" ))
oInvPc:refresh()
* Grabar Log
cLog += cBarcode+strzero(nCant,4,0)+strzero(nActual,4,0)+dtos(date())+time()+cEncargado + CR
memowrit( files_dir+"download\inventa.log" , cLog )
IF nActual == nCant
oMsg:VarPut( "!! INVENTARIO CORRECTO, CONTINUE !!")
oCant:VarPut(1)
ELSEIF nCant > nActual // Sobrantes
oMsg:VarPut( "!! SOBRANTES, CUENTE DE NUEVO !!" )
oCant:VarPut(-999)
ELSEIF nCant < nActual // Faltantes
oMsg:VarPut( "!! FALTANTES, CUENTE DE NUEVO !!" )
oCant:VarPut(-999)
ENDIF
nContador := nContador + 1
oContador:VarPut("Contador:"+transform(nContador,"999"))
lReturn := .T.
ELSE
oMsg:VarPut( "!! CODIGO DE BARRAS ESTA VACIO!!" )
oCant:VarPut(1)
ENDIF
ELSE
oMsg:VarPut( "!! ARTICULO NO EXISTE, INTENTE DE NUEVO !!" )
oCant:VarPut(1)
ENDIF
* ELSE
* if empty( cBarcode )
* oMsg:VarPut( "!! TECLE SU CODIGO DE BARRAS!!" )
* endif
* ENDIF
oMsg:refresh()
oCant:refresh()
oContador:refresh()
IF lReturn
oBarCode:oJump := oCant
ENDIF
RETURN lReturn
FUNCTION GrabaEncargado()
* begin
LOCAL cFile , cRet , cVar
IF oEncargado:nLastKey = 13
IF lUsers
IF USERS->(DbSeek(cEncargado))
cVar := cBarcode+strzero(nCant,4,0)+strzero(nExist,4,0)+dtos(date())+time()+cEncargado + CR
cLog += cVAr
oCant:VarPut(1)
oCant:refresh()
oBarCode:VarPut(space(15))
oBarCode:refresh()
oMsg:VarPut( "SE GRABO DIFERENCIAS :"+alltrim(USERS->user_name))
oMsg:refresh()
oInvPC:VarPut( "Inventario PC:"+transform( 0 ,"99999" ))
oInvPc:refresh()
oEncargado:VarPut(space(15))
oEncargado:refresh()
oEncargado:oJump := oCant
ELSE
msginfo( "Empleado no exite" )
RETURN .F.
ENDIF
ENDIF
ENDIF
RETURN .T.
FUNCTION Existencias( cBarCode )
* Begin
LOCAL cFile := files_dir+"download\"+alltrim(cBarcode)+"*.exi"
LOCAL aFiles := Directory( cFile )
LOCAL nCount := Len(aFiles)
LOCAL nExist := NIL
LOCAL i
asort( aFiles ,,, {|aX,aY|dtos(aX[F_DATE ])+aX[F_TIME] < dtos(aY[F_DATE ])+aY[F_TIME]})
FOR i := 1 TO nCount
nExist := val( substr( aFiles[i][1] , len( aFiles[i][1])-7 ) )
NEXT
IF nExist = NIL
nExist := -777
ENDIF
RETURN nExist
* Funciones que no corren en Symbol MC3000
FUNCTION cesetmenu() ; RETURN NIL
FUNCTION getmenu() ; RETURN NIL
FUNCTION readbitmap() ; RETURN NIL
FUNCTION palbmpread() ; RETURN NIL
****************************************************************************************************
#pragma BEGINDUMP
#include <hbapi.h>
#include <windows.h>
#include <Scancapi.h>
#include <mmsystem.h>
#include <uniqueid.h>
LPWSTR AnsiToWide( LPSTR );
#define BUFFER_SIZE 7095
#define DEFAULT_TIMEOUT 10000
LPSCAN_BUFFER lpScanBuffer = NULL;
BOOL bUseText = TRUE;
DWORD dwScanSize = 7095;
DWORD dwScanTimeout = 0;
HANDLE hScanner = NULL;
TCHAR szScannerName[MAX_PATH] = TEXT("SCN1:");
DWORD dwResult ;
CHAR Buffer ;
UINT uMsg ;
DWORD dwTimeout ;
HB_FUNC( SCAN_OPEN )
{
dwResult = SCAN_Open( szScannerName, &hScanner );
if ( dwResult == E_SCN_SUCCESS )
{
dwResult = SCAN_Enable( hScanner );
if ( dwResult == E_SCN_SUCCESS )
{
BOOL state = TRUE;
dwResult = SCAN_SetSoftTrigger(hScanner, &state);
if (dwResult == E_SCN_SUCCESS)
{
// allocate a new scan buffer
lpScanBuffer = SCAN_AllocateBuffer(TRUE /* data as chars */, BUFFER_SIZE);
if (lpScanBuffer)
{
dwResult = SCAN_ReadLabelWait(hScanner, lpScanBuffer, DEFAULT_TIMEOUT);
if (dwResult == E_SCN_SUCCESS)
{
hb_retclen( (char *)SCNBUF_GETDATA(lpScanBuffer),28);
}
}
SCAN_DeallocateBuffer(lpScanBuffer);
}
state = FALSE;
SCAN_SetSoftTrigger(hScanner, &state);
}
else
{
MessageBox( GetActiveWindow(), L"Error en SCAN_Enable", L"Ok", 0 );
}
}
else
{
MessageBox( GetActiveWindow(), L"Error en SCAN_Open", L"Ok", 0 );
}
}
HB_FUNC (STILLRUN)
{
HWND hWnd;
BOOL lRet = FALSE;
LPWSTR pW = AnsiToWide( hb_parc( 1 ) );
hWnd = FindWindow ( NULL,pW);
if (hWnd)
{
SetForegroundWindow ((HWND) ((ULONG) hWnd |0x01));
lRet = TRUE;
}
hb_retl( lRet );
}
HB_FUNC (BATTERYLIFE)
{
BOOL iRet;
SYSTEM_POWER_STATUS_EX status;
iRet = GetSystemPowerStatusEx (&status, TRUE);
hb_retnl ((INT) status.BatteryLifePercent);
}
HB_FUNC (BATTERYINFO)
{
BOOL iRet;
SYSTEM_POWER_STATUS_EX status;
iRet = GetSystemPowerStatusEx (&status, TRUE);
hb_reta (9);
hb_stornl ((INT) status.ACLineStatus, -1, 1);
hb_stornl ((INT) status.BatteryFlag, -1, 2);
hb_stornl ((INT) status.BatteryLifePercent, -1, 3);
hb_stornl ((ULONG) status.BatteryLifeTime, -1, 4);
hb_stornl ((ULONG) status.BatteryFullLifeTime, -1, 5);
hb_stornl ((INT) status.BackupBatteryFlag, -1, 6);
hb_stornl ((INT) status.BackupBatteryLifePercent, -1, 7);
hb_stornl ((ULONG) status.BackupBatteryLifeTime, -1, 8);
hb_stornl ((ULONG) status.BackupBatteryFullLifeTime, -1, 9);
}
#pragma ENDDUMP