454 lines
12 KiB
C++
454 lines
12 KiB
C++
#include "stdafx.h"
|
|
#include "CHZXGDlg.h"
|
|
#include "ADDXGDLG.h"
|
|
#include "uiiado.h"
|
|
#include "ktcadutility.h"
|
|
|
|
IMPLEMENT_DYNAMIC(CHZXGDlg, CDialog)
|
|
|
|
CHZXGDlg::CHZXGDlg(CWnd *pParent /*=NULL*/)
|
|
: CDialog(CHZXGDlg::IDD, pParent)
|
|
{
|
|
memset(&m_xGPipeData, 0, sizeof(XGPipeData));
|
|
m_bXGPipeData = false;
|
|
|
|
m_bEnableSelRoad = FALSE;
|
|
m_idRoad.setNull();
|
|
}
|
|
|
|
CHZXGDlg::~CHZXGDlg()
|
|
{
|
|
}
|
|
|
|
void CHZXGDlg::DoDataExchange(CDataExchange *pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
DDX_Control(pDX, IDC_LIST1, m_wndList);
|
|
DDX_Control(pDX, IDC_BUTTON2, m_wndBtSelect);
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CHZXGDlg, CDialog)
|
|
ON_BN_CLICKED(IDOK, &CHZXGDlg::OnBnClickedOk)
|
|
ON_BN_CLICKED(IDC_BUTTON2, &CHZXGDlg::OnBnClickedButton2)
|
|
ON_BN_CLICKED(IDC_BUTTON1, &CHZXGDlg::OnBnClickedButton1)
|
|
ON_BN_CLICKED(IDC_BUTTON3, &CHZXGDlg::OnBnClickedButton3)
|
|
ON_BN_CLICKED(IDC_BUTTON5, &CHZXGDlg::OnBnClickedButton5)
|
|
END_MESSAGE_MAP()
|
|
|
|
BOOL CHZXGDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
CBitmap bmp;
|
|
if (!bmp.LoadBitmap(IDB_TOOLBAR))
|
|
{
|
|
AfxMessageBox(_T("Can't load bitmap: %x\n"), IDB_TOOLBAR);
|
|
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_wndList.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT | LVS_EX_SINGLEROW);
|
|
|
|
m_wndList.InsertColumn(0, _T("序号"), LVCFMT_LEFT, 50);
|
|
m_wndList.InsertColumn(1, _T("品名"), LVCFMT_LEFT, 160);
|
|
m_wndList.InsertColumn(2, _T("材质"), LVCFMT_LEFT, 100);
|
|
m_wndList.InsertColumn(3, _T("外径"), LVCFMT_LEFT, 60);
|
|
m_wndList.InsertColumn(4, _T("壁厚"), LVCFMT_LEFT, 60);
|
|
m_wndList.InsertColumn(5, _T("公称直径"), LVCFMT_LEFT, 80);
|
|
m_wndList.InsertColumn(6, _T("弯曲半径"), LVCFMT_LEFT, 80);
|
|
m_wndList.InsertColumn(7, _T("工作温度"), LVCFMT_LEFT, 100);
|
|
m_wndList.InsertColumn(8, _T("公称压力"), LVCFMT_LEFT, 100);
|
|
m_wndList.InsertColumn(9, _T("阻燃等级"), LVCFMT_LEFT, 100);
|
|
m_wndList.InsertColumn(10, _T("牌号"), LVCFMT_LEFT, 60);
|
|
m_wndList.InsertColumn(11, _T("型号"), LVCFMT_LEFT, 120);
|
|
m_wndList.InsertColumn(12, _T("结构形式"), LVCFMT_LEFT, 120);
|
|
m_wndList.InsertColumn(13, _T("生产厂家"), LVCFMT_LEFT, 200);
|
|
|
|
ShowNormalXPipes();
|
|
|
|
m_wndBtSelect.ShowWindow(m_bEnableSelRoad ? SW_SHOW : SW_HIDE);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void CHZXGDlg::ShowNormalXPipes()
|
|
{
|
|
//从本地数据库读取线管数据
|
|
CUIISQLiteServer db;
|
|
if (db.InitADOServer(FilePath::GetSysDir() + _T("\\plumbing.db")))
|
|
{
|
|
CString sSQL, sNo,sText;
|
|
//表的字段顺序和listctrl一致
|
|
sSQL = _T("select PName,Material,OD,Thick,DN,DR,WorkTmp,Pre,FlameR,TM,Model,StruF,Provider from aeccasepipe");
|
|
|
|
CUIIValueTable table;
|
|
db.GetSelData(sSQL, table);
|
|
int nItem = 0;
|
|
CStringArray arRec;
|
|
for (int i = 0;i < table.GetTableLogicSize();i++)
|
|
{
|
|
arRec.RemoveAll();
|
|
table.GetValueRecord(i, arRec);
|
|
|
|
sNo.Format(_T("%d"), i + 1);
|
|
nItem = m_wndList.InsertItem(i, sNo,0);
|
|
|
|
if (arRec.GetSize() >= m_wndList.GetHeaderCtrl()->GetItemCount() - 1)
|
|
{
|
|
for (int ii = 0;ii < m_wndList.GetHeaderCtrl()->GetItemCount()-1;ii++)
|
|
{
|
|
sText = arRec.GetAt(ii);
|
|
m_wndList.SetItemText(nItem, ii+1, sText);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
AfxMessageBox(_T("连结访问数据库 plumbing 失败!"));
|
|
}
|
|
}
|
|
|
|
//new
|
|
void CHZXGDlg::OnBnClickedButton1()
|
|
{
|
|
// 等待李工上传文件
|
|
#ifdef CADDXGDLG
|
|
int nNo = m_wndList.GetItemCount() + 1;
|
|
CString sNo;
|
|
sNo.Format(_T("%d"), nNo);
|
|
|
|
CADDXGDLG dlg;
|
|
dlg.SetNo(sNo);
|
|
if (IDOK == dlg.DoModal() )
|
|
{
|
|
CStringArray &arData = dlg.m_arData;
|
|
CString sSQL,sNo, sText;
|
|
|
|
/*
|
|
[Provider] varchar(255),
|
|
[StruF] varchar(255),
|
|
[Model] varchar(255),
|
|
[TM] varchar(255),
|
|
[FlameR] varchar(255),
|
|
[Pre] double,
|
|
[WorkTmp] varchar(256),
|
|
[DR] double,
|
|
[DN] int,
|
|
[Thick] double,
|
|
[OD] double,
|
|
[Material] varchar(256),
|
|
[PName] varchar(256));
|
|
*/
|
|
|
|
sSQL.Format(_T("insert into aeccasepipe (PName,Material,OD,Thick,DN,DR,WorkTmp,Pre,FlameR,TM,Model,StruF,Provider) \
|
|
values ('%s','%s',%s,%s,%s,%s,'%s',%s,'%s','%s','%s','%s','%s')"),
|
|
arData.GetAt(1),
|
|
arData.GetAt(2),
|
|
arData.GetAt(3),
|
|
arData.GetAt(4),
|
|
arData.GetAt(5),
|
|
arData.GetAt(6),
|
|
arData.GetAt(7),
|
|
arData.GetAt(8),
|
|
arData.GetAt(9),
|
|
arData.GetAt(10),
|
|
arData.GetAt(11),
|
|
arData.GetAt(12),
|
|
arData.GetAt(13) );
|
|
|
|
//从本地数据库读取线管数据
|
|
CUIISQLiteServer db;
|
|
if (db.InitADOServer(FilePath::GetSysDir() + _T("\\plumbing.db")))
|
|
{
|
|
if (db.ExecuteSQL(sSQL))
|
|
{
|
|
sNo.Format(_T("%d"), m_wndList.GetItemCount() + 1);
|
|
int nItem = m_wndList.InsertItem(m_wndList.GetItemCount(), sNo, 0);
|
|
|
|
for (int ii = 1; ii < m_wndList.GetHeaderCtrl()->GetItemCount(); ii++)
|
|
{
|
|
sText = arData.GetAt(ii);
|
|
m_wndList.SetItemText(nItem, ii, sText);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
AfxMessageBox(_T("连结访问数据库 plumbing 失败!"));
|
|
}
|
|
}
|
|
#endif
|
|
}
|
|
|
|
//mod
|
|
void CHZXGDlg::OnBnClickedButton5()
|
|
{
|
|
// 等待李工上传文件
|
|
#ifdef CADDXGDLG
|
|
POSITION ps = m_wndList.GetFirstSelectedItemPosition();
|
|
if (ps != NULL)
|
|
{
|
|
int nSel = m_wndList.GetNextSelectedItem(ps);
|
|
if (nSel != -1)
|
|
{
|
|
CString sText;
|
|
CStringArray arData;
|
|
for (int i = 0;i < m_wndList.GetHeaderCtrl()->GetItemCount();i++)
|
|
{
|
|
sText = m_wndList.GetItemText(nSel, i);
|
|
arData.Add(sText);
|
|
}
|
|
|
|
CString sNo = arData.GetAt(0);
|
|
|
|
CADDXGDLG dlg;
|
|
dlg.SetNo(sNo);
|
|
dlg.Add2Modi(arData);
|
|
|
|
if (IDOK == dlg.DoModal())
|
|
{
|
|
arData.RemoveAll();
|
|
arData.Append(dlg.m_arData);
|
|
|
|
|
|
CStringArray &arData = dlg.m_arData;
|
|
CString sSQL,sNo, sText;
|
|
|
|
/*
|
|
[Provider] varchar(255),
|
|
[StruF] varchar(255),
|
|
[Model] varchar(255),
|
|
[TM] varchar(255),
|
|
[FlameR] varchar(255),
|
|
[Pre] double,
|
|
[WorkTmp] varchar(256),
|
|
[DR] double,
|
|
[DN] int,
|
|
[Thick] double,
|
|
[OD] double,
|
|
[Material] varchar(256),
|
|
[PName] varchar(256));
|
|
*/
|
|
|
|
//修改数据库
|
|
//PName,Material,OD,Thick,DN,DR,WorkTmp,Pre
|
|
CString PName, Material, OD, Thick, DN, DR, WorkTmp, Pre;
|
|
|
|
PName = m_wndList.GetItemText(nSel, 1);
|
|
Material = m_wndList.GetItemText(nSel, 2);
|
|
OD = m_wndList.GetItemText(nSel, 3);
|
|
Thick = m_wndList.GetItemText(nSel, 4);
|
|
DN = m_wndList.GetItemText(nSel, 5);
|
|
DR = m_wndList.GetItemText(nSel, 6);
|
|
WorkTmp = m_wndList.GetItemText(nSel, 7);
|
|
Pre = m_wndList.GetItemText(nSel, 8);
|
|
|
|
//更新list
|
|
for (int ii = 1; ii < m_wndList.GetHeaderCtrl()->GetItemCount(); ii++)
|
|
{
|
|
sText = arData.GetAt(ii);
|
|
m_wndList.SetItemText(nSel, ii, sText);
|
|
}
|
|
|
|
//先删除,后插入
|
|
sSQL.Format(_T("delete from aeccasepipe where PName='%s' and Material LIKE '%%%s' \
|
|
and OD>%.2f and OD<%.2f and Thick>%.2f and Thick<%.2f and DN=%d \
|
|
and DR>%.2f and DR<%.2f and WorkTmp='%s' and Pre>%.2f and Pre<%.2f"),
|
|
PName, Material, _ttof(OD) - 0.01, _ttof(OD) + 0.01, _ttof(Thick) - 0.01, _ttof(Thick) + 0.01, _ttoi(DN),
|
|
_ttof(DR) - 0.01, _ttof(DR) + 0.01, WorkTmp, _ttof(Pre) - 0.01, _ttof(Pre) + 0.01);
|
|
|
|
//从本地数据库读取线管数据
|
|
CUIISQLiteServer db;
|
|
if (db.InitADOServer(FilePath::GetSysDir() + _T("\\plumbing.db")))
|
|
{
|
|
if (db.ExecuteSQL(sSQL))
|
|
{
|
|
sSQL.Format(_T("insert into aeccasepipe (PName,Material,OD,Thick,DN,DR,WorkTmp,Pre,FlameR,TM,Model,StruF,Provider) \
|
|
values ('%s','%s',%s,%s,%s,%s,'%s',%s,'%s','%s','%s','%s','%s')"),
|
|
arData.GetAt(1),
|
|
arData.GetAt(2),
|
|
arData.GetAt(3),
|
|
arData.GetAt(4),
|
|
arData.GetAt(5),
|
|
arData.GetAt(6),
|
|
arData.GetAt(7),
|
|
arData.GetAt(8),
|
|
arData.GetAt(9),
|
|
arData.GetAt(10),
|
|
arData.GetAt(11),
|
|
arData.GetAt(12),
|
|
arData.GetAt(13));
|
|
|
|
db.ExecuteSQL(sSQL);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endif
|
|
}
|
|
|
|
//del
|
|
void CHZXGDlg::OnBnClickedButton3()
|
|
{
|
|
POSITION ps = m_wndList.GetFirstSelectedItemPosition();
|
|
if (ps != NULL)
|
|
{
|
|
int nSel = m_wndList.GetNextSelectedItem(ps);
|
|
if (nSel != -1)
|
|
{
|
|
//PName,Material,OD,Thick,DN,DR,WorkTmp,Pre
|
|
CString PName, Material, OD, Thick, DN, DR, WorkTmp, Pre,sSQL;
|
|
|
|
PName = m_wndList.GetItemText(nSel, 1);
|
|
Material = m_wndList.GetItemText(nSel, 2);
|
|
OD = m_wndList.GetItemText(nSel, 3);
|
|
Thick = m_wndList.GetItemText(nSel, 4);
|
|
DN = m_wndList.GetItemText(nSel, 5);
|
|
DR = m_wndList.GetItemText(nSel, 6);
|
|
WorkTmp = m_wndList.GetItemText(nSel, 7);
|
|
Pre = m_wndList.GetItemText(nSel, 8);
|
|
|
|
sSQL.Format(_T("delete from aeccasepipe where PName='%s' and Material LIKE '%%%s' \
|
|
and OD>%.2f and OD<%.2f and Thick>%.2f and Thick<%.2f and DN=%d \
|
|
and DR>%.2f and DR<%.2f and WorkTmp='%s' and Pre>%.2f and Pre<%.2f"),
|
|
PName,Material,_ttof(OD)-0.01,_ttof(OD)+0.01,_ttof(Thick)-0.01,_ttof(Thick)+0.01,_ttoi(DN),
|
|
_ttof(DR)-0.01,_ttof(DR)+0.01,WorkTmp,_ttof(Pre)-0.01,_ttof(Pre)+0.01);
|
|
|
|
/*
|
|
m_wndList.InsertColumn(1, _T("品名"), LVCFMT_LEFT, 160);
|
|
m_wndList.InsertColumn(2, _T("材质"), LVCFMT_LEFT, 100);
|
|
m_wndList.InsertColumn(3, _T("外径"), LVCFMT_LEFT, 60);
|
|
m_wndList.InsertColumn(4, _T("壁厚"), LVCFMT_LEFT, 60);
|
|
m_wndList.InsertColumn(5, _T("公称直径"), LVCFMT_LEFT, 80);
|
|
m_wndList.InsertColumn(6, _T("弯曲半径"), LVCFMT_LEFT, 80);
|
|
m_wndList.InsertColumn(7, _T("工作温度"), LVCFMT_LEFT, 100);
|
|
m_wndList.InsertColumn(8, _T("公称压力"), LVCFMT_LEFT, 100);
|
|
*/
|
|
|
|
//从本地数据库读取线管数据
|
|
CUIISQLiteServer db;
|
|
if (db.InitADOServer(FilePath::GetSysDir() + _T("\\plumbing.db")))
|
|
{
|
|
if (db.ExecuteSQL(sSQL))
|
|
{
|
|
m_wndList.DeleteItem(nSel);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
AfxMessageBox(_T("连结访问数据库 plumbing 失败!"));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void CHZXGDlg::OnBnClickedOk()
|
|
{
|
|
int nSel = 0;
|
|
CString sItem;
|
|
|
|
POSITION ps = m_wndList.GetFirstSelectedItemPosition();
|
|
if (ps != NULL)
|
|
{
|
|
nSel = m_wndList.GetNextSelectedItem(ps);
|
|
if (nSel != -1)
|
|
{
|
|
m_bXGPipeData = true;
|
|
|
|
sItem = m_wndList.GetItemText(nSel, 0);//序号
|
|
|
|
sItem = m_wndList.GetItemText(nSel, 1);//品名
|
|
_tcscpy(m_xGPipeData.szPName, (LPCTSTR)sItem);
|
|
|
|
sItem = m_wndList.GetItemText(nSel, 2);//材质
|
|
_tcscpy(m_xGPipeData.szPName, (LPCTSTR)sItem);
|
|
|
|
sItem = m_wndList.GetItemText(nSel, 3);//外径
|
|
m_xGPipeData.dOD = _ttof(sItem);
|
|
|
|
sItem = m_wndList.GetItemText(nSel, 4);//壁厚
|
|
m_xGPipeData.dt = _ttof(sItem);
|
|
|
|
sItem = m_wndList.GetItemText(nSel, 5);//公称直径
|
|
m_xGPipeData.dDN = _ttof(sItem);
|
|
|
|
sItem = m_wndList.GetItemText(nSel, 6);//弯曲半径,非曲率
|
|
m_xGPipeData.dDR = _ttof(sItem);
|
|
|
|
sItem = m_wndList.GetItemText(nSel, 7);//工作温度
|
|
_tcscpy(m_xGPipeData.szWorkTmp, (LPCTSTR)sItem);
|
|
|
|
sItem = m_wndList.GetItemText(nSel, 8);//公称压力
|
|
m_xGPipeData.dPre = _ttof(sItem);
|
|
|
|
sItem = m_wndList.GetItemText(nSel, 9);//阻燃等级
|
|
_tcscpy(m_xGPipeData.szFlameR, (LPCTSTR)sItem);
|
|
|
|
sItem = m_wndList.GetItemText(nSel, 10);//牌号
|
|
_tcscpy(m_xGPipeData.szTM, (LPCTSTR)sItem);
|
|
|
|
sItem = m_wndList.GetItemText(nSel, 11);//型号
|
|
_tcscpy(m_xGPipeData.szModel, (LPCTSTR)sItem);
|
|
|
|
sItem = m_wndList.GetItemText(nSel, 12);//结构形式
|
|
_tcscpy(m_xGPipeData.szStruF, (LPCTSTR)sItem);
|
|
|
|
sItem = m_wndList.GetItemText(nSel, 13);//生产厂家
|
|
_tcscpy(m_xGPipeData.szProvider, (LPCTSTR)sItem);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
AfxMessageBox(_T("请选择一条线管创建线管!"));
|
|
return;
|
|
}
|
|
OnOK();
|
|
}
|
|
|
|
#ifndef DXF_PATH
|
|
#define DXF_PATH _T("LINE,LWPOLYLINE,AEC_ROADAXISLINE")
|
|
#endif
|
|
|
|
void CHZXGDlg::OnBnClickedButton2()
|
|
{
|
|
EnableWindow(FALSE);
|
|
CWnd *pFrame = acedGetAcadFrame();
|
|
pFrame->EnableWindow(TRUE);
|
|
ShowWindow(SW_HIDE);
|
|
pFrame->SetFocus();
|
|
|
|
struct resbuf *pRb1 = acutBuildList(RTDXF0, DXF_PATH, 0);
|
|
ads_name ent1;
|
|
int nRes = CKTCadUtility::SelectEntity(_T("\n选择路径:"), ent1, pRb1);
|
|
if (nRes == RTNORM)
|
|
{
|
|
AcDbObjectId id;
|
|
acdbGetObjectId(m_idRoad, ent1);
|
|
}
|
|
acutRelRb(pRb1);
|
|
|
|
pFrame->EnableWindow(FALSE);
|
|
ShowWindow(SW_SHOW);
|
|
EnableWindow(TRUE);
|
|
}
|
|
|
|
bool CHZXGDlg::GetXGPipeData(XGPipeData &data) const
|
|
{
|
|
memcpy(&data, &m_xGPipeData, sizeof(XGPipeData));
|
|
return m_bXGPipeData;
|
|
}
|
|
|
|
void CHZXGDlg::SetXGPipeData(XGPipeData &data)
|
|
{
|
|
//更改
|
|
memcpy(&m_xGPipeData, &data, sizeof(XGPipeData));
|
|
} |