// Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// General information section.
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// $Author:yongkiang$ User who last changed the file
// $Date:1/2/2013 12:16:46 PM$ Date and time of last check in
// $Revision:1.0$ Visual SourceSafe version number
// $Workfile::   RecipePackagePage.h                                   $ Filename
// End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// {{AFX_INCLUDES()
#include "MainSheet.h"
#include "MyPropertyPage.h"
// }}AFX_INCLUDES
#if !defined(AFX_RECIPEPACKAGEPAGE_H__F29FE0F6_79B7_11D6_A7FF_005004C029CA__INCLUDED_)
#define AFX_RECIPEPACKAGEPAGE_H__F29FE0F6_79B7_11D6_A7FF_005004C029CA__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// RecipePackagePage.h : header file
//
#ifdef  BUILD_GUIDLL
#define     DLLCLASS    __declspec(dllexport)
#else
#define     DLLCLASS    __declspec(dllimport)
#endif

#include "PromptExceptionMessage.h"
#include "BtnST.h"
#include "ShadeButtonST.h"

/////////////////////////////////////////////////////////////////////////////
// CRecipePackagePage dialog

class DLLCLASS CRecipePackagePage : public CMyPropertyPage // public CPropertyPage
{
DECLARE_DYNCREATE(CRecipePackagePage)

// Construction
public:
    virtual void SetPagesTabText();
    virtual bool ImportPackage();
    virtual bool ExportPackage();
    virtual bool CopyPackage();
    virtual bool AddNewPackage();
    virtual void CopyToNewPackageInfo(CString csNewPackage, CString csExistingPackage);
    virtual void ClosePackageEdit(void);
    virtual void DisplaySubPages(CString csPackageName);
    CRecipePackagePage();
    ~CRecipePackagePage();

// flag to indicate that the Package setup is using wizard
    bool         m_bUseWizardMethod;
    CStringArray m_csaAvailablePackageName;

    CString m_csExportImportMsg;

// Dialog Data
// {{AFX_DATA(CRecipePackagePage)
    enum {
        IDD = IDD_RECIPE_PACKAGE_PAGE
    };
    CListCtrl      m_ReportListCtrl;
    CShadeButtonST m_fileBtn;
    CShadeButtonST m_printBtn;
    CShadeButtonST m_pageSetupBtn;
    CComboBox      m_cbWhichReportToPrint;
    CShadeButtonST m_cbRenameBtn;
    CShadeButtonST m_cbNewBtn;
    CShadeButtonST m_cbEditBtn;
    CShadeButtonST m_cbCopyBtn;
    CShadeButtonST m_deleteBtn;
    CListCtrl      m_listCtrl;
    CString        m_csNewPackageName;
    CButton        m_bCopyDeviceInfo;
    CButton        m_bCopyMotorPosition;
    CButton        m_bCopyMotorSpeed;
    CShadeButtonST m_cbExportBtn;
    CShadeButtonST m_cbImportBtn;
// }}AFX_DATA

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

// Implementation
protected:
    void SetPackageName(CString csPackageName);
    bool CheckHaveDefaultInfo(CString *csMessage = NULL);
    bool CheckHaveDefaultMotorPos();
    bool CheckHaveDefaultMotorSpeed();
    bool CheckHaveDefaultPackageInfo();
    bool CheckDuplicatePackage(void);

    BOOL CreateNewPackage(void);

// Generated message map functions
// {{AFX_MSG(CRecipePackagePage)
    afx_msg virtual void OnExportButton();
    afx_msg virtual void OnImportButton();
    virtual BOOL         OnInitDialog();
    afx_msg void         OnEditButton();
    afx_msg void         OnDeleteButton();
    afx_msg void         OnNewButton();
    afx_msg void         OnCopyButton();

#if _MSC_VER > 1200 // Version Higher than VC6
    afx_msg void OnRenameButton();
#else // VC 6 Version
    afx_msg void OnRenameButton(bool bThruBtn = true);
#endif

    afx_msg void OnDblclkPackageList(NMHDR* pNMHDR, LRESULT* pResult);
    afx_msg void OnEndlabeleditPackageList(NMHDR* pNMHDR, LRESULT* pResult);
    afx_msg void OnTimer(UINT nIDEvent);
    afx_msg void OnRecipeFileButton();
    afx_msg void OnRecipePageSetupButton();
    afx_msg void OnRecipePrintButton();
// }}AFX_MSG
    DECLARE_MESSAGE_MAP()
    virtual void CreateNewMtrPosRec();                         // create new MotorPos record
    virtual void CreateNewMtrSpdRec();                         // create new MotorSpeed record
//  Add new package record to record set
    void         AddNewPackageRecord(CDaoRecordset &RecordSet, CString csSQL);
    virtual void DelNewMtrPosRec(bool bGoldenData = false);    // delete motor position record in MitPkg.mdb
    virtual void DelNewMtrSpdRec(bool bGoldenData = false);    // delete motor speed record in MitPkg.mdb
    virtual void RenameNewMtrPosRec(bool bGoldenData = false); // rename the package name in MotorPos record
    virtual void RenameNewMtrSpdRec(bool bGoldenData = false); // rename the package name in MotorSpeed record
//  copy existing package Motor position record to a new record
    virtual void CopyToNewMtrPosRec(CString csNewPackage, CString csExistingPackage);
//  copy existing package Motor Speed record to a new record
    virtual void CopyToNewMtrSpdRec(CString csNewPackage, CString csExistingPackage);
//  copy record field from existing package to new package
    virtual bool CopyRecField(CDaoRecordset &NewPkgRS, CDaoRecordset &ExistPkgRS, CString csTable,
                              CString csNewPkg, CString csExistingPkg, int iStartFieldNo, int iRecNo);

    virtual BOOL CopyToNewPackage(CString csNewPackage, CString csExistingPackage);

private:
    int  UpdateDeviceInfoToListCtrl(int iNextRowCount = 0);
    int  UpdateDeviceInfoToListCtrl(CDaoRecordset &RecordSet, CString csSql, int iNextRowCount = 0, int iSn = 0);
    int  UpdateMotorPosToListCtrl(int iNextRowCount = 0);
    bool IsDefaultPackage();
    BOOL CheckLotInfoUsingPackage(void);
    BOOL Rename(bool bGoldenData = false);
    BOOL GetSelectedPackage(void);
    BOOL CheckNewPackageName(void);
    BOOL DeletePackage(bool bGoldenData = false);
    BOOL CheckCurrentPackage(void);
    void InitListCtrl(void);
    void InitListCtrlData(void);
    BOOL CheckPackageAppearedInRecipeRS(void);

    void DisplayIn2ndLang();
    void InitIconButtons();

//  Initialised List control
    void InitReportListCtrl(int iType);

// init combo box Printing Report selection
    void InitComboBox();

    enum MESSAGE_FOR_PRINTING_SELECTION
    {
        ALL,
        DEVICE_INFO,
        MOTOR_POSITION,
    };

//  CMainDoc* m_pDoc;
//  CFont m_fontLogo;
    CString m_csSelectedPackage;
    CString m_csNew;

/// 0 = Use MotorPos Table else 1 = Use MotorPosition Table
    bool m_bUseMotorPosTable;

#if _MSC_VER > 1200 // Version Higher than VC6
    bool m_bThruBtn;
#endif
};

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

#endif // !defined(AFX_RECIPEPACKAGEPAGE_H__F29FE0F6_79B7_11D6_A7FF_005004C029CA__INCLUDED_)
