#if !defined(AFX_EXPORTIMPORTWIZARD_H__031F3886_4D4C_423E_B167_0BB21D6E4246__INCLUDED_)
#define AFX_EXPORTIMPORTWIZARD_H__031F3886_4D4C_423E_B167_0BB21D6E4246__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ExportImportWizard.h : header file
//
#include "ShadeButtonST.h"
#include "MyPropertyPage.h"

#ifdef  BUILD_GUIDLL
#define     DLLCLASS    __declspec(dllexport)
#else
#define     DLLCLASS    __declspec(dllimport)
#endif

/////////////////////////////////////////////////////////////////////////////
// CExportImportWizard dialog

class DLLCLASS CExportImportWizard : public CMyPropertyPage
{
DECLARE_DYNCREATE(CExportImportWizard)

// Construction
public:
    CExportImportWizard(bool bCopyPkgInfo = true, bool bCopyMtrPos = true,
                        bool bCopyMtrSpd = true);

    CExportImportWizard(int nPageNo, int nDataTransferType, bool bCopyPkgInfo = true, bool bCopyMtrPos = true,
                        bool bCopyMtrSpd = true);

// Gary 22Dec09, silent import operation
    CExportImportWizard(int nDataTransferType, CString csFilename, bool bCopyPkgInfo = true, bool bCopyMtrPos = true,
                        bool bCopyMtrSpd = true);

// Gary 04Jan10, silent export operation
    CExportImportWizard(int nDataTransferType, CString csFilename, CString csPackageName, bool bCopyPkgInfo = true,
                        bool bCopyMtrPos = true, bool bCopyMtrSpd = true);

    ~CExportImportWizard();

    enum
    {
        PACKAGE_DATA_EXPORT,
        PACKAGE_DATA_IMPORT,
        //  PACKAGE_DATA_IMPORT_2,
        RECEIPE_DATA_EXPORT,
        RECEIPE_DATA_IMPORT,

        PACKAGE_RECIPE_IMPORT_SILENT,
        PACKAGE_RECIPE_EXPORT_SILENT,
    };

    enum EXPORT_IMPORT_PACKAGE_RECEIPE_PAGE_NO
    {
        PACKAGE_EXPORT_CHOOSE_PAGE,
        PACKAGE_IMPORT_CHOOSE_PAGE,
    };

    CStringArray m_csaSelectedPackageName;

    CString m_csActivityMessage;

// Dialog Data
// {{AFX_DATA(CExportImportWizard)
    enum {
        IDD = IDD_EXPORT_IMPORT_WIZARD
    };
    CShadeButtonST m_ExportImportRemoveAllBn;
    CShadeButtonST m_ExportImportAddAllBn;
    CShadeButtonST m_ExportImportRemoveBn;
    CShadeButtonST m_ExportImportAddInBn;
    CListCtrl      m_lcExportImportDestinationList;
    CListCtrl      m_lcExportImportSourceList;
// }}AFX_DATA

// Overrides
// ClassWizard generate virtual function overrides
// {{AFX_VIRTUAL(CExportImportWizard)
public:
    virtual BOOL OnSetActive();
    virtual BOOL OnWizardFinish();
protected:
    virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
// }}AFX_VIRTUAL

// Implementation
protected:
    bool PrepareFileForImport(CString csFilename);
    void CopyRecipeManagementRecords(CDaoDatabase *pTargetDB, CDaoDatabase *pSourceDB, CString csPackage);
// Generated message map functions
// {{AFX_MSG(CExportImportWizard)
    virtual BOOL    OnInitDialog();
    virtual LRESULT OnWizardNext();
    afx_msg void    OnExportImportAddInButton();
    afx_msg void    OnExportImportRemoveButton();
    afx_msg void    OnExportImportRomoveAllButton();
    afx_msg void    OnExportImportAddAllButton();
    afx_msg void    OnDblclkExportImportSourceList(NMHDR* pNMHDR, LRESULT* pResult);
    afx_msg void    OnDblclkExportImportDestinationList(NMHDR* pNMHDR, LRESULT* pResult);
// }}AFX_MSG
    DECLARE_MESSAGE_MAP()

private:
    void SetImportFileName(CString csImportFileName);
    void InitIconButtons();
    void SetPageTitleText();
    void CopyPackageIntoCurrentDatabase(CString csPackageName, bool bCopyPkg = true, bool bCopyMtrPos = true,
                                        bool bCopyMtrSpd = true);
    void DeletePackageInfo(CString csPackageName, bool bDelPkg = true, bool bDelMtrPos = true, bool bDelMtrSpd = true);
    bool IfSelectedPackageAlreadyInsideDB(CString csPackageName);
    bool ComparePackageInfoField(CString csSelectedFileName, int nWhichTable);
    bool IfSelectedPackageDBCompatible(CString csSelectedFileName);
    void OnRefreshDestinationList();
    void OnRefreshSourceList();
    void InitListCtrl();
    bool ImportPackage();
    void CreateNewMtrSpdRecord(CDaoRecordset &RecordSet, CString csNewPackageName, CString csTable = "MotorSpeed");
    void AddNewPackageRecord(CDaoRecordset &RecordSet, CString csSQL, CString csNewPackageName);
    void CopyToNewMtrSpdRecords(CDaoDatabase *pTargetDB, CDaoDatabase *pSourceDB, CString csNewPackage, CString csExistingPackage, CString csTable = "MotorSpeed");
    void CopyToNewMtrPosRecords(CDaoDatabase *pTargetDB, CDaoDatabase *pSourceDB, CString csNewPackage, CString csExistingPackage, CString csTable = "MotorPosition");
    bool CopyFieldInfo(CDaoDatabase *pTargetDB, CDaoDatabase *pSourceDB, CString csTableName);
    bool CreateNewTable(CDaoDatabase *pDatabase, CString csNewTableName);
    bool CopyRecField(CDaoRecordset &NewPkgRS, CDaoRecordset &ExistPkgRS, CString csTable,
                      CString csNewPkg, CString csExistingPkg, int iStartFieldNo, int iRecNo);
    bool CreateNewPackageInfo(CString csFilePath, CString csPackageName);
    bool ExportPackage();
    void SetPageInfoText();
    bool ProcessWizardNextButton();
    int m_nPageNo;
    int m_nDataTransferType;

    enum // Database Table Name
    {
        PACKAGE_INFO,
        MOTOR_POSITION,
        MOTOR_SPEED,
    };

    CString m_csSelectedAddInName;
    CString m_csSelectedRemoveName;
    CString m_csPackageName;
    CString m_csExportFileName;
    CString m_csExportPackageName;
    CString m_csImportFileName;

    CStringArray m_csaSelectedAddInName;
    CStringArray m_csaSelectedRemoveName;

    bool m_bSilentMode;
    bool m_bCopyPkgInfo;
    bool m_bCopyMtrPos;
    bool m_bCopyMtrSpd;
};

// {{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_EXPORTIMPORTWIZARD_H__031F3886_4D4C_423E_B167_0BB21D6E4246__INCLUDED_)
