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

#ifndef crd_ctrlH
#define crd_ctrlH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ExtCtrls.hpp>
#include <Graphics.hpp>
#include <ComCtrls.hpp>
#include <Db.hpp>
#include <DBTables.hpp>
#include <DBCtrls.hpp>
#include <Buttons.hpp>
#include <DB.hpp>
//---------------------------------------------------------------------------
class TCardCtrl : public TForm
{
__published:	// IDE-managed Components
        TPanel *Panel1;
        TLabel *Label1;
        TBevel *Bevel1;
        TImage *CardOK;
        TStatusBar *StatusBar1;
        TBevel *Bevel2;
        TLabel *noCardFound;
        TDataSource *DsCards;
        TTable *TbCards;
        TLabel *Label2;
        TDBText *DBText1;
        TLabel *Label3;
        TDBText *DBText2;
        TDBCheckBox *DBCheckBox1;
        TLabel *Label4;
        TDBLookupComboBox *DBLookupComboBox1;
        TGroupBox *GroupBox1;
        TDBCheckBox *DBCheckBox2;
        TDBText *DBText3;
        TDBText *DBText4;
        TBitBtn *GrabaTarjera;
        TBitBtn *BitBtn2;
        TBitBtn *VerificarTarjeta;
        void __fastcall BitBtn2Click(TObject *Sender);
        void __fastcall GrabaTarjeraClick(TObject *Sender);
        void __fastcall VerificarTarjetaClick(TObject *Sender);
        void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
private:	// User declarations
        // ------------ PARA EL GRABADOR --------------
        int PuertoE;
        int cb_PosP, cb_LenP;
        int cb_PosC, cb_LenC;
        int cb_PosR, cb_LenR;
        int cb_PosFd, cb_LenFd;
        int cb_PosFh, cb_LenFh;
        HANDLE LM_handle;

        int  __fastcall AbrePuerto(LPTSTR lpszPortName);
        char * __fastcall ObtenerRespuesta( char *rcv );
        char * __fastcall EnviaCMD1( char *CMD, char *rcv, char mlen );
        char * __fastcall EnviaCMD( char *CMD, char *rcv );
        char __fastcall CalculaBCC( char *cadena );
        // ---------- FIN PARA EL GRABADOR ------------
        char * __fastcall ObtenCadenaTarjeta(char *dev);



public:		// User declarations
        void  __fastcall CierraPuerto(void);
        char * __fastcall LeeTarjeta( char *rcv );
        char * __fastcall EscribeTarjeta( char *datos, char *rcv );

        __fastcall TCardCtrl(TComponent* Owner);
        int __fastcall LocateCard( int idc, int owner );

        bool LM_opened, statusOK;
        int IDcard;

};
//---------------------------------------------------------------------------
extern PACKAGE TCardCtrl *CardCtrl;
//---------------------------------------------------------------------------
#endif
