//---------------------------------------------------------------------------

#ifndef mainH
#define mainH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include "VidGrab.hpp"
#include <ExtCtrls.hpp>
#include "ZAbstractDataset.hpp"
#include "ZAbstractRODataset.hpp"
#include "ZConnection.hpp"
#include "ZDataset.hpp"
#include <DB.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:	// IDE-managed Components
        TVideoGrabber *VideoGrabber1;
        TTimer *Timer1;
        TLabel *clock;
        TLabel *txt0;
        TTimer *Timer2;
        TImage *Image1;
        TLabel *barCode01;
        TLabel *barCode02;
        TZConnection *ZConnection1;
        TZQuery *ZQuery1;
        TZQuery *ZQuery2;
        TLabel *txt1;
        void __fastcall FormPaint(TObject *Sender);
        void __fastcall FormResize(TObject *Sender);
        void __fastcall VideoGrabber1FrameCaptureCompleted(TObject *Sender,
          const TFrameData &FrameData, TFrameCaptureDest DestType,
          AnsiString FileName, bool Success);
        void __fastcall FormCloseQuery(TObject *Sender, bool &CanClose);
        void __fastcall VideoGrabber1PreviewStarted(TObject *Sender);
        void __fastcall Timer1Timer(TObject *Sender);
        void __fastcall FormKeyPress(TObject *Sender, char &Key);
        void __fastcall Timer2Timer(TObject *Sender);
        void __fastcall ZConnection1AfterDisconnect(TObject *Sender);
        void __fastcall ZConnection1BeforeConnect(TObject *Sender);
        void __fastcall ZConnection1AfterConnect(TObject *Sender);
private:	// User declarations
        TPicture *pFondoAPP;
        bool camPreviewStarted;
        void __fastcall showText(AnsiString txt, AnsiString txtAux);

        bool __fastcall existeUsuario( int uid, char *ultimoEstado, AnsiString *user );
        void __fastcall picarEntradaUsuario( int uid );
        int __fastcall tieneOrdenTrabajoAbierta( int uid );
        bool __fastcall existeOrdenTrabajo( int orden, int uid, AnsiString *estado );
        void __fastcall cierraTrabajo( int uid, int orden );
        void __fastcall iniciaTrabajo( int uid, int orden );
        void __fastcall cierraTrabajos( int uid );
        void __fastcall picarSalidaUsuario( int uid );

        void __fastcall initDB(void);

        char ultimoEstado;
        AnsiString currentUser;
        int currentUID;
        int nextTry;

public:		// User declarations
        __fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
