#pragma once

#include <vector>
#include <string>

#include "Structure.h"
#include "ado2.h"
#include "DllDefines.h"

// MotorPositionRS.h : header file
//

/////////////////////////////////////////////////////////////////////////////
// CMotorPositionRS recordset

class MCCTRDLLCLASS CMotorPositionRS
{
public:
    CMotorPositionRS();
    virtual ~CMotorPositionRS();

    // Field/Param Data
    long m_ID;
    std::string m_Module_Name;
    std::string m_Motor_Name;
    std::string m_Position_Name;
    BOOL m_Teach_Enable;
    BOOL m_Save_All_Pkg;

    // Overrides
public:
    virtual std::string GetDefaultDBName(); // Default database name
    virtual std::string GetDefaultSQL();    // Default SQL for Recordset


    //  Close Recordset and close database
    virtual void Close();

// Implementation
#ifdef _DEBUG
    virtual void AssertValid() const;
    virtual void Dump(CDumpContext& dc) const;
#endif

    void InitMotorModule(std::vector<stModule>& modules); // Function to init motor module to maintenance page

    //  get Save all pkg
    BOOL GetSaveAllPkg(std::string csPosName);

    int GetNoOfMtrs(std::vector<stModule>& modules);

private:
    CADODatabase m_db;
    CADORecordset m_rs;

    bool Open(std::string sqlQuery);
    void GetAllFieldsValue();

    int GetModuleIndex(std::vector<stModule>& modules); // return the module index
    void initNoOfMtr(std::vector<stModule>& modules);   // initialised no of motor to 0
};
