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

#ifndef Das_Loader_Log_AnalysisH
#define Das_Loader_Log_AnalysisH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include "ChartfxLib_OCX.h"
#include "FPSpread_OCX.h"
#include <ComCtrls.hpp>
#include <Dialogs.hpp>
#include <ExtCtrls.hpp>
#include <Menus.hpp>
#include <OleCtrls.hpp>
//---------------------------------------------------------------------------
//user space
#include <Registry.hpp>
#include <Filectrl.hpp>
#include <dir.h>
#include "ChartFull.h"

#define adUseServer 2
#define adModeReadWrite 3
#define adXactCursorStability 4096

#define adLockOptimistic 3
#define adExecuteRecord 0x800
#define adOpenKeyset	  1

// STL을 사용하기 위한 포함
#ifndef _STL_
#include <vector>
using namespace std;
#endif _STL_

//---------------------------------------------------------------------------
struct Block
    {
        long start;
        long rows;
    };
class TDasLoaderLogAnalysis_Main : public TForm
{
__published:	// IDE-managed Components
        TGroupBox *GroupBox1;
        TPanel *Panel1;
        TLabel *Label4;
        TTreeView *TreeView1;
        TEdit *Edit3;
        TEdit *Edit4;
        TButton *Search;
        TEdit *Edit5;
        TGroupBox *GroupBox3;
        TLabel *Label1;
        TButton *GETRECIPE;
        TDateTimePicker *DateTimePicker1;
        TDateTimePicker *DateTimePicker2;
        TDateTimePicker *DateTimePicker3;
        TDateTimePicker *DateTimePicker4;
        TvaSpread *vaSpread2;
        TvaSpread *vaSpread3;
        TvaSpread *vaSpread4;
        TGroupBox *GroupBox2;
        TLabel *Label2;
        TLabel *Label3;
        TButton *RecipeToLot;
        TButton *LotToCST;
        TPageControl *PageControl1;
        TTabSheet *TabSheet1;
        TGroupBox *GroupBox6;
        TButton *Import;
        TButton *Export;
        TButton *Delete;
        TvaSpread *vaSpread1;
        TTabSheet *TabSheet2;
        TChartFX *ChartFX1;
        TTabSheet *TabSheet3;
        TChartFX *ChartFX2;
        TTabSheet *TabSheet4;
        TChartFX *ChartFX3;
        TTabSheet *TabSheet5;
        TChartFX *ChartFX4;
        TButton *Full_Screen_BT;
        TOpenDialog *OpenDialog1;
        TSaveDialog *SaveDialog1;
        TMainMenu *MainMenu1;
        TMenuItem *File;
        TMenuItem *BackUpData;
        TMenuItem *OpenDB;
        TMenuItem *OpenFileXSL;
        TMenuItem *SaveasXSL;
    TMenuItem *Exit;
        TSaveDialog *SaveDialog2;
        TOpenDialog *OpenDialog2;
        TOpenDialog *OpenPictureDialog1;
        void __fastcall FormCreate(TObject *Sender);
        void __fastcall Change_DTime(TObject *Sender);
        void __fastcall GETRECIPEClick(TObject *Sender);
        void __fastcall RECIPE_Head_Click(TObject *Sender, long Col,
          long Row);
        void __fastcall Recipe_Select(TObject *Sender, WORD &Key,
          TShiftState Shift);
        void __fastcall RecipeToLotClick(TObject *Sender);
        void __fastcall Lot_Head_Click(TObject *Sender, long Col,
          long Row);
        void __fastcall LOT_Select(TObject *Sender, WORD &Key,
          TShiftState Shift);
        void __fastcall LotToCSTClick(TObject *Sender);
        void __fastcall CST_Head_Click(TObject *Sender, long Col,
          long Row);
        void __fastcall Full_Screen_BTClick(TObject *Sender);
        void __fastcall ImportClick(TObject *Sender);
        void __fastcall ExportClick(TObject *Sender);
        void __fastcall DeleteClick(TObject *Sender);
        void __fastcall PageControl1Change(TObject *Sender);
        void __fastcall SearchClick(TObject *Sender);
        void __fastcall OpenFileXSLClick(TObject *Sender);
        void __fastcall BackUpDataClick(TObject *Sender);
        void __fastcall OpenDBClick(TObject *Sender);
        void __fastcall SaveasXSLClick(TObject *Sender);
    void __fastcall ExitClick(TObject *Sender);
private:	// User declarations
        Variant commandobject;
        Variant RecordSetDB;
        Variant FieldsBr;
        Variant Catalog;

public:		// User declarations
        __fastcall TDasLoaderLogAnalysis_Main(TComponent* Owner);

        void __fastcall Create_DB(AnsiString DB_file_name);
        void __fastcall Default_Create_DB(AnsiString FileName);
        void __fastcall DB_Connect(void);
        void __fastcall DAY_CHART_VIEW(void);
        void __fastcall RECIPE_CHART_VIEW(void);
        void __fastcall LOT_CHART_VIEW(void);
        void __fastcall RECIPE_LOT_CHART_VIEW(void);

        void __fastcall CheckAll(TvaSpread *Spread, int inum);
        void __fastcall UnCheckAll(TvaSpread *Spread, int inum);
        int  __fastcall FQuery(TvaSpread *Spread, AnsiString Query);
        void __fastcall ReadField(TvaSpread *Spread);
        bool __fastcall Get_Null_Row(TvaSpread *Spread, int row);
        bool __fastcall GetCheckState(TvaSpread *Spread);
        bool __fastcall GetCheckList(TvaSpread *Spread, AnsiString &Query);
        int  __fastcall GetCheckCount(TvaSpread *Spread);
        Variant __fastcall GetCheckText(TvaSpread *Spread, int index);
        AnsiString __fastcall Get_Spread_Value(TvaSpread *Spread, int MaxCol, int row);

        void __fastcall Header_Click(TvaSpread *Spread, long Col, long Row);
        bool __fastcall RowHeader_Selecting_State(TvaSpread *Spread);

        AnsiString  __fastcall DTime_Select(void);

        AnsiString  __fastcall Get_Eqp_Process(TTreeView *TreeView);
        AnsiString __fastcall Get_EQP_Name(TTreeView *TreeView, int level, int index);
        AnsiString __fastcall Get_PROCESS_Name(TTreeView *TreeView, int level, int index);
        int __fastcall Get_Process_Count(TTreeView *TreeView, int level);

        Variant  __fastcall Query_Get_Count(AnsiString Query);
        bool  __fastcall Sql_Query(AnsiString Query);
        void __fastcall SetLegendLabel(TChartFX *ChartFX, int iSeriesIndex, AnsiString& strLabel);

        int __fastcall Get_All_Sibling(TTreeNode* Node);
        int __fastcall GetTreeCheck(TTreeNode* pItem);
        int __fastcall SetTreeCheck(TTreeNode* pNode, int iState);
        int __fastcall SetTreeCheck(int iIndex, int iState);

        TTreeNode* __fastcall SetAllSubNode(TTreeNode* ParentNode, TTreeNode* Node);
        void __fastcall quick_sort(Block Dim[], long lb, long ub);

};
//---------------------------------------------------------------------------
extern PACKAGE TDasLoaderLogAnalysis_Main *DasLoaderLogAnalysis_Main;
//---------------------------------------------------------------------------
#endif
