191 lines
4.4 KiB
C++
191 lines
4.4 KiB
C++
#include "stdafx.h"
|
|
#include "XXSBDlg.h"
|
|
|
|
#define IMG_FOLDER 0
|
|
#define IMG_CLASS 1
|
|
|
|
IMPLEMENT_DYNAMIC(CXXSBDlg, CDialog)
|
|
|
|
CXXSBDlg::CXXSBDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(CXXSBDlg::IDD, pParent)
|
|
, m_nInfs(2)
|
|
{
|
|
m_sPrefix = _T("Aec_");
|
|
m_sFolderShow = _T("");
|
|
m_pDb = NULL;
|
|
}
|
|
|
|
CXXSBDlg::~CXXSBDlg()
|
|
{
|
|
}
|
|
|
|
void CXXSBDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
DDX_Control(pDX, IDC_TREEEQUIP, m_wndEquipPrmTree);
|
|
DDX_Text(pDX, IDC_EDIT2, m_nInfs);
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CXXSBDlg, CDialog)
|
|
ON_BN_CLICKED(IDOK, &CXXSBDlg::OnBnClickedOk)
|
|
ON_NOTIFY(TVN_SELCHANGED, IDC_TREEEQUIP, &CXXSBDlg::OnTvnSelchangedTreeequip)
|
|
END_MESSAGE_MAP()
|
|
|
|
void CXXSBDlg::OnBnClickedOk()
|
|
{
|
|
UpdateData();
|
|
|
|
if (m_sFolder.IsEmpty() || m_sName.IsEmpty())
|
|
{
|
|
AfxMessageBox(_T("请选择小型设备名称!"));
|
|
return;
|
|
}
|
|
|
|
if (m_nInfs < 1)
|
|
{
|
|
AfxMessageBox(_T("小型设备至少有一个管嘴!"));
|
|
return;
|
|
}
|
|
|
|
OnOK();
|
|
}
|
|
|
|
BOOL CXXSBDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
CBitmap bmp;
|
|
if (!bmp.LoadBitmap (IDB_BITMAPDIR))
|
|
{
|
|
AfxMessageBox(_T ("Can't load bitmap: %x\n"), IDB_BITMAPPRIV);
|
|
ASSERT (FALSE);
|
|
return FALSE;
|
|
}
|
|
|
|
BITMAP bmpObj;
|
|
bmp.GetBitmap (&bmpObj);
|
|
|
|
UINT nFlags = ILC_COLOR24 | ILC_MASK;
|
|
|
|
m_Imagelist.Create (16, bmpObj.bmHeight, nFlags, 0, 0);
|
|
m_Imagelist.Add (&bmp, RGB (255, 0, 0));
|
|
m_wndEquipPrmTree.SetImageList(&m_Imagelist,TVSIL_NORMAL);
|
|
|
|
CString dbPath = FilePath::GetSysDir();
|
|
dbPath += _T("\\Aec3DMep.db");
|
|
if (_taccess(dbPath, 0x00) != 0x00)
|
|
{
|
|
AfxMessageBox(_T("系统没有找到Aec3DMep.db文件!请检查软件是否正确安装!"));
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL bSuccess = FALSE;
|
|
if (m_pDb != NULL)
|
|
bSuccess = m_pDb->InitADOServer(dbPath);
|
|
|
|
if (!bSuccess)
|
|
{
|
|
AfxMessageBox(_T("数据库驱动加载数据库Aec3DMep.db失败!"));
|
|
return FALSE;
|
|
}
|
|
|
|
ShowEquipFolder();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void CXXSBDlg::ShowEquipFolder()
|
|
{
|
|
CString sSQL,sKey;
|
|
if (m_sFolderShow.IsEmpty())
|
|
{
|
|
//sSQL = _T("select id,folder from aec_folder");
|
|
sSQL.Format(_T("select id,folder from %sfolder"), m_sPrefix);
|
|
}
|
|
else
|
|
{
|
|
//sSQL.Format(_T("select id,folder from aec_folder where folder='%s'"),m_sFolderShow);
|
|
sSQL.Format(_T("select id,folder from %sfolder where folder='%s'"), m_sPrefix, m_sFolderShow);
|
|
}
|
|
|
|
CStringArray arFolders;
|
|
CUIIValueTable table;
|
|
|
|
m_pDb->GetSelData(sSQL,table);
|
|
for (int i = 0;i < table.GetTableLogicSize();i++)
|
|
{
|
|
arFolders.RemoveAll();
|
|
table.GetValueRecord(i,arFolders);
|
|
|
|
if (arFolders.GetSize() >= 2)
|
|
{
|
|
HTREEITEM hItem = m_wndEquipPrmTree.InsertItem(arFolders.GetAt(1),IMG_FOLDER,IMG_FOLDER);
|
|
ShowEquipClass(hItem,arFolders.GetAt(0));
|
|
m_wndEquipPrmTree.Expand(hItem,TVE_EXPAND);
|
|
|
|
sKey.Format(_T("%p"),hItem);
|
|
m_mapItem2FolderID.SetAt(sKey,arFolders.GetAt(0));
|
|
}
|
|
}
|
|
}
|
|
|
|
void CXXSBDlg::ShowEquipClass(HTREEITEM hFolder,LPCTSTR pszFolderID)
|
|
{
|
|
CString sSQL,sKey;
|
|
|
|
if (m_sClassShow.IsEmpty())
|
|
{
|
|
//sSQL.Format(_T("select id,class from aec_class where idfolder='%s'"),pszFolderID);
|
|
sSQL.Format(_T("select id,class from %sclass where idfolder='%s'"), m_sPrefix,pszFolderID);
|
|
}
|
|
else
|
|
{
|
|
//sSQL.Format(_T("select id,class from aec_class where idfolder='%s' and class like '%%%s%%'"),pszFolderID,m_sClassShow);
|
|
sSQL.Format(_T("select id,class from %sclass where idfolder='%s' and class='%s'"), m_sPrefix,pszFolderID,m_sClassShow);
|
|
}
|
|
|
|
CStringArray arClass;
|
|
CUIIValueTable table;
|
|
|
|
m_pDb->GetSelData(sSQL,table);
|
|
|
|
if (table.GetTableLogicSize() == 0)
|
|
{
|
|
if (!m_sClassShow.IsEmpty())
|
|
{
|
|
sSQL.Format(_T("select id,class from %sclass where idfolder='%s' and class like '%s'"), m_sPrefix,pszFolderID,m_sClassShow);
|
|
m_pDb->GetSelData(sSQL,table);
|
|
}
|
|
}
|
|
|
|
for (int i = 0;i < table.GetTableLogicSize();i++)
|
|
{
|
|
arClass.RemoveAll();
|
|
table.GetValueRecord(i,arClass);
|
|
|
|
if (arClass.GetSize() >= 2)
|
|
{
|
|
HTREEITEM hItem = m_wndEquipPrmTree.InsertItem(arClass.GetAt(1),IMG_CLASS,IMG_CLASS,hFolder);
|
|
sKey.Format(_T("%p"),hItem);
|
|
m_mapItem2FolderID.SetAt(sKey,arClass.GetAt(0));
|
|
}
|
|
}
|
|
}
|
|
|
|
void CXXSBDlg::OnTvnSelchangedTreeequip(NMHDR *pNMHDR, LRESULT *pResult)
|
|
{
|
|
LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);
|
|
|
|
int nImage = -1,nSelImg = -1;
|
|
m_wndEquipPrmTree.GetItemImage(pNMTreeView->itemNew.hItem,nImage,nSelImg);
|
|
|
|
if (nImage == IMG_CLASS)
|
|
{
|
|
m_sName = m_wndEquipPrmTree.GetItemText(pNMTreeView->itemNew.hItem);
|
|
}
|
|
else if (nImage == IMG_FOLDER)
|
|
{
|
|
m_sFolder = m_wndEquipPrmTree.GetItemText(pNMTreeView->itemNew.hItem);
|
|
}
|
|
*pResult = 0;
|
|
} |