//---------------------------------------------------------------------------
#ifndef DViewerH
#define DViewerH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Db.hpp>
#include <DBTables.hpp>
#include <DBGrids.hpp>
#include <Grids.hpp>
#include <Buttons.hpp>
#include <ExtCtrls.hpp>
#include <ComCtrls.hpp>
#include <CheckLst.hpp>
#include <Chart.hpp>
#include <Series.hpp>
#include <TeEngine.hpp>
#include <TeeProcs.hpp>
#include <ImgList.hpp>
#include <DBCtrls.hpp>
#include <Mask.hpp>
#include "elastfrm.hpp"
#include "ElastFrm.hpp"
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
class TDViewerF : public TForm
{
__published:	// IDE-managed Components
    TTable *TbHistorico;
    TDataSource *DsHistorico;
    TIntegerField *TbHistoricoNumElement;
    TDateTimeField *TbHistoricoFComienzo;
    TTimeField *TbHistoricoTiempo;
    TIntegerField *TbHistoricoidc;
    TIntegerField *TbHistoricoidtc;
    TCurrencyField *TbHistoricoprecio;
    TStringField *TbHistoricoTipoConexion;
    TTable *TbElementos;
    TStringField *TbHistoricoNombreTerminal;
    TDataSource *DsElementos;
    TStatusBar *StatusBar1;
    TPanel *Panel2;
    TPanel *Panel3;
        TDateTimePicker *MinFecha;
    TComboBox *idtConexion;
        TCheckListBox *Equipos;
        TDateTimePicker *MaxFecha;
        TLabel *Label1;
        TLabel *Label2;
        TSplitter *Splitter1;
        TProgressBar *ProgressBar1;
        TPageControl *PageControl1;
        TTabSheet *TabSheet1;
        TLabel *Label3;
        TLabel *Label4;
        TLabel *Label5;
        TLabel *Label6;
        TTabSheet *TabSheet2;
        TChart *ConexionesEquipos;
        TTabSheet *TabSheet3;
        TChart *TipoConexion;
        TPieSeries *Series3;
        TTabSheet *TabSheet4;
        TChart *ConexionesHora;
        TLabel *Label7;
        TLabel *Label8;
        TLabel *Label9;
        TLabel *Label10;
        TComboBox *MargenRuptura;
        TLabel *Label11;
        TPageControl *PageControl2;
        TTabSheet *TabSheet5;
        TDBGrid *DBGrid1;
        TTabSheet *TabSheet6;
        TBevel *Bevel1;
        TStringGrid *StringGrid1;
        TLabel *Label12;
        TLabel *Label13;
        TLabel *NBonos;
        TBarSeries *Series1;
        TBarSeries *Series2;
        TAreaSeries *Series4;
        TAreaSeries *Series5;
        TButton *Button1;
        TTabSheet *TabSheet7;
        TDBGrid *DBGrid2;
        TTable *TbPersonas;
        TTable *TbBonos;
        TDataSource *DsBonos;
        TIntegerField *TbBonosIDcliente;
        TDateTimeField *TbBonosFechaCompra;
        TIntegerField *TbBonosBhoras;
        TIntegerField *TbBonosBmin;
        TCurrencyField *TbBonoscoste;
        TStringField *TbBonosNombreClt;
        TStringField *TbBonosApellidos;
        TLabel *Label14;
        TLabel *BonosVendidos;
        TButton *Button2;
        TTabSheet *TabSheet8;
        TImageList *Historicos;
        TPanel *Panel1;
        TDBGrid *DBGrid3;
        TDataSource *DsPersonas;
        TTable *TbBonosCliente;
        TDataSource *DsBonosClientes;
        TComboBox *SelIndex;
        TEdit *Edit1;
        TDBNavigator *DBNavigator1;
        TBevel *Bevel2;
        TLabel *Label15;
        TLabel *Label16;
        TLabel *Label17;
        TDBEdit *DBEdit1;
        TLabel *Label18;
        TDBText *DBText1;
        TDBEdit *DBEdit2;
        TDBEdit *DBEdit3;
        TDBEdit *DBEdit4;
        TLabel *Label19;
        TDBEdit *DBEdit5;
        TDBEdit *DBEdit6;
        TShape *Shape1;
        TShape *Shape2;
        TLabel *Label20;
        TDBText *DBText2;
        TButton *Button3;
        TButton *Button4;
        TElasticForm *ElasticForm1;
    void __fastcall TbHistoricoBeforeOpen(TDataSet *DataSet);
    void __fastcall TbHistoricoCalcFields(TDataSet *DataSet);
    void __fastcall MinFechaChange(TObject *Sender);

    void __fastcall DBGrid1DrawColumnCell(TObject *Sender,
          const TRect &Rect, int DataCol, TColumn *Column,
          TGridDrawState State);
        void __fastcall TbElementosAfterOpen(TDataSet *DataSet);
        void __fastcall FormDestroy(TObject *Sender);
        void __fastcall idtConexionChange(TObject *Sender);
        void __fastcall Button1Click(TObject *Sender);
        void __fastcall Button2Click(TObject *Sender);
        void __fastcall Edit1KeyUp(TObject *Sender, WORD &Key,
          TShiftState Shift);
        void __fastcall DBEdit1KeyUp(TObject *Sender, WORD &Key,
          TShiftState Shift);
        void __fastcall DBEdit2KeyUp(TObject *Sender, WORD &Key,
          TShiftState Shift);
        void __fastcall DBEdit3KeyUp(TObject *Sender, WORD &Key,
          TShiftState Shift);
        void __fastcall DBEdit4KeyUp(TObject *Sender, WORD &Key,
          TShiftState Shift);
        void __fastcall DBEdit5KeyUp(TObject *Sender, WORD &Key,
          TShiftState Shift);
        void __fastcall DBEdit6KeyUp(TObject *Sender, WORD &Key,
          TShiftState Shift);
        void __fastcall TbPersonasBeforeDelete(TDataSet *DataSet);
        void __fastcall TbPersonasNewRecord(TDataSet *DataSet);
        void __fastcall Button4Click(TObject *Sender);
        void __fastcall Button3Click(TObject *Sender);
        void __fastcall EquiposClick(TObject *Sender);

private:	// User declarations
    int __fastcall Obten_idtc(void);
    bool TerminalFiltered;
    void __fastcall RefiltraDatos(void);

public:		// User declarations
    __fastcall TDViewerF(TComponent* Owner);
    void __fastcall CalculaGraficas(void);
    void __fastcall InsertaEnParrilla( int Elto, Currency CantidadF, TDateTime Tiempo, bool Repetido );

    struct DatosEltos
    {
     int Elto;
     int ConF, ConR;
     Currency TotalF, TotalR;
     int horasF, minF;
     int horasR, minR;
    } *Parrilla;

    int NConexionesTipo[8];
    int ConexionesHoraF[48], ConexionesHoraR[48];

    int NBonosVendidos;
    Currency TotalBonos;
};
//---------------------------------------------------------------------------
extern PACKAGE TDViewerF *DViewerF;
//---------------------------------------------------------------------------
#endif
