426 lines
14 KiB
C++
426 lines
14 KiB
C++
// SelectPumpDlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
|
|
//#include <cbclass.h>
|
|
|
|
#include "SelectPumpDlg.h"
|
|
#include "twt_pump.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
//#ifdef _WIN64
|
|
#include "TGAs.h"
|
|
//#endif
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// 水泵选型
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
void SelectPumpCmd()
|
|
{
|
|
CTemporaryResourceOverride vTemp;
|
|
CSelectPumpDlg dlg;
|
|
if(dlg.DoModal() != IDOK)
|
|
return;
|
|
}
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CSelectPumpDlg dialog
|
|
|
|
|
|
CSelectPumpDlg::CSelectPumpDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(CSelectPumpDlg::IDD, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(CSelectPumpDlg)
|
|
m_nQ = 0.0;
|
|
m_nH = 0.0;
|
|
m_iPumpType = 0;
|
|
m_iFactory = 0;
|
|
//}}AFX_DATA_INIT
|
|
m_iLenght = 0;
|
|
m_iWidth = 0;
|
|
m_iHeight = 0;
|
|
m_nRetQ = 0;
|
|
m_nRetRaise = 0;
|
|
m_nRetH = 0;
|
|
m_nRetH2 = 0;
|
|
m_nRetH3 = 0;
|
|
m_csRetSpec = _T("");
|
|
m_nDeep = 0.0;
|
|
}
|
|
|
|
|
|
void CSelectPumpDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CSelectPumpDlg)
|
|
DDX_Control(pDX, IDC_COMBO_FACTARY, m_comboFactory);
|
|
DDX_Control(pDX, IDC_COMBO_TYPE, m_comboType);
|
|
DDX_Control(pDX, IDC_LIST_PUMP, m_listCtrl);
|
|
DDX_Text(pDX, IDC_EDIT_Q, m_nQ);
|
|
DDX_Text(pDX, IDC_EDIT_H, m_nH);
|
|
DDX_CBIndex(pDX, IDC_COMBO_TYPE, m_iPumpType);
|
|
DDX_CBIndex(pDX, IDC_COMBO_FACTARY, m_iFactory);
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CSelectPumpDlg, CDialog)
|
|
//{{AFX_MSG_MAP(CSelectPumpDlg)
|
|
ON_CBN_SELCHANGE(IDC_COMBO_TYPE, OnSelchangeComboType)
|
|
ON_WM_PAINT()
|
|
ON_CBN_SELCHANGE(IDC_COMBO_FACTARY, OnSelchangeComboFactary)
|
|
ON_NOTIFY(NM_DBLCLK, IDC_LIST_PUMP, OnDblclkListPump)
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CSelectPumpDlg message handlers
|
|
|
|
|
|
BOOL CSelectPumpDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
|
|
CodeBase db;
|
|
XString fullFile;
|
|
if(!FindFile(_T("pump.dbf"), fullFile)) {
|
|
AfxMessageBox(_T("对不起,没有发现pump.dbf文件!"));
|
|
return TRUE;
|
|
}
|
|
XDbfTable *pTable = db.Open(fullFile);
|
|
if(!pTable)
|
|
return TRUE;
|
|
CString csFactory;
|
|
for(pTable->MoveFirst();!pTable->IsEOF();pTable->MoveNext()){
|
|
GET_FIELD(pTable, _T("Owner"), csFactory);
|
|
if(m_lstFactory.Index(csFactory) < 0 && csFactory != _T(""))
|
|
m_lstFactory.Append(tstrnew(csFactory));
|
|
}
|
|
for(int i=0;i<m_lstFactory.Length();i++){
|
|
m_comboFactory.AddString(m_lstFactory[i]);
|
|
}
|
|
m_listCtrl.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT);
|
|
m_listCtrl.InsertColumn ( 0, _T("泵型号"), LVCFMT_LEFT, 90 );
|
|
m_listCtrl.InsertColumn ( 1, _T("流量(L/s)"), LVCFMT_LEFT, 100 );
|
|
m_listCtrl.InsertColumn ( 2, _T("扬程(m)"), LVCFMT_LEFT, 100 );
|
|
m_listCtrl.InsertColumn ( 3, _T("功率KW"), LVCFMT_LEFT, 50 );
|
|
m_listCtrl.InsertColumn ( 4, _T("重量kg"), LVCFMT_LEFT, 50 );
|
|
m_listCtrl.InsertColumn ( 5, _T("基座长"), LVCFMT_LEFT, 50 );
|
|
m_listCtrl.InsertColumn ( 6, _T("基座宽"), LVCFMT_LEFT, 50 );
|
|
m_listCtrl.InsertColumn ( 7, _T("H"), LVCFMT_LEFT, 50 );
|
|
m_listCtrl.InsertColumn ( 8, _T("h1"), LVCFMT_LEFT, 50 );
|
|
m_listCtrl.InsertColumn ( 9, _T("h2"), LVCFMT_LEFT, 50 );
|
|
m_listCtrl.InsertColumn ( 10, _T("L1"), LVCFMT_LEFT, 50 );
|
|
m_listCtrl.InsertColumn ( 11, _T("L2"), LVCFMT_LEFT, 50 );
|
|
m_listCtrl.InsertColumn ( 12, _T("螺栓孔深"), LVCFMT_CENTER, 60 );
|
|
|
|
m_iPumpType = 0;
|
|
m_iFactory = 1;
|
|
UpdateData(FALSE);
|
|
OnSelchangeComboFactary();
|
|
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
|
}
|
|
|
|
|
|
void CSelectPumpDlg::OnSelchangeComboType()
|
|
{
|
|
Reset();
|
|
}
|
|
|
|
void CSelectPumpDlg::OnSelchangeComboFactary()
|
|
{
|
|
UpdateData(TRUE);
|
|
CodeBase db;
|
|
XString fullFile;
|
|
|
|
CString csCurFactory = m_lstFactory[m_iFactory];
|
|
|
|
if(!FindFile(_T("pump.dbf"), fullFile)) {
|
|
AfxMessageBox(_T("对不起,没有发现pump.dbf文件!"));
|
|
return;
|
|
}
|
|
XDbfTable *pTable = db.Open(fullFile);
|
|
if(!pTable)
|
|
return;
|
|
m_comboType.ResetContent();
|
|
m_lstType.Reset();
|
|
CString csType, csFactory;
|
|
for(pTable->MoveFirst();!pTable->IsEOF();pTable->MoveNext()){
|
|
GET_FIELD(pTable, _T("Type"), csType);
|
|
GET_FIELD(pTable, _T("Owner"), csFactory);
|
|
if(m_lstType.Index(csType) < 0 && csType != _T("") && csFactory == csCurFactory)
|
|
m_lstType.Append(tstrnew(csType));
|
|
}
|
|
for(int i=0;i<m_lstType.Length();i++){
|
|
m_comboType.AddString(m_lstType[i]);
|
|
}
|
|
m_iPumpType = 0;
|
|
UpdateData(FALSE);
|
|
Reset();
|
|
}
|
|
|
|
void CSelectPumpDlg::OpenSlide()
|
|
{
|
|
UpdateData(TRUE);
|
|
CWnd *pImageBox = GetDlgItem(IDC_PREVIEW_SETUP);
|
|
CString csSldName;
|
|
CString csCurType = m_lstType[m_iPumpType];
|
|
|
|
// zxl 2013.10.31 modify
|
|
// if(csCurType == _T("IS1450"))
|
|
// csSldName = _T("pump(00000024)");
|
|
// else if(csCurType == _T("IS2900"))
|
|
// csSldName = _T("pump(00000024)");
|
|
// else if(csCurType == _T("DL"))
|
|
// csSldName = _T("pump(00000025)");
|
|
// else if(csCurType == _T("FLG、FLGR"))
|
|
// csSldName = _T("pump(00000036)");
|
|
// else if(csCurType == _T("FWG、FWGR"))
|
|
// csSldName = _T("pump(00000037)");
|
|
// else if(csCurType == _T("KQL"))
|
|
// csSldName = _T("pump(00000052)");
|
|
// else if(csCurType == _T("KQW"))
|
|
// csSldName = _T("pump(00000051)");
|
|
// else if(csCurType == _T("XBD-DN"))
|
|
// csSldName = _T("pump(00000058)");
|
|
|
|
CString csCurFactory = m_lstFactory[m_iFactory];
|
|
if (csCurType == _T("FLG"))
|
|
csSldName = _T("pump(00000063)");
|
|
else if (csCurType == _T("FWG"))
|
|
csSldName = _T("pump(00000069)");
|
|
else if (csCurType == _T("DL") && csCurFactory == _T("上海东方泵业"))
|
|
csSldName = _T("pump(00000064)");
|
|
else if (csCurType == _T("SLS"))
|
|
csSldName = _T("pump(00000068)");
|
|
else if (csCurType == _T("GDL"))
|
|
csSldName = _T("pump(00000067)");
|
|
else if (csCurType == _T("SLW"))
|
|
csSldName = _T("pump(00000071)");
|
|
else if (csCurType == _T("DFL"))
|
|
csSldName = _T("pump(00000065)");
|
|
else if (csCurType == _T("DL"))
|
|
csSldName = _T("pump(00000066)");
|
|
else if (csCurType == _T("DFW"))
|
|
csSldName = _T("pump(00000070)");
|
|
|
|
DrawSlide((const TCHAR*)csSldName, pImageBox);
|
|
}
|
|
|
|
void CSelectPumpDlg::Reset()
|
|
{
|
|
UpdateData(TRUE);
|
|
CString csCurType = m_lstType[m_iPumpType];
|
|
CString csCurFactory = m_lstFactory[m_iFactory];
|
|
CodeBase db;
|
|
XString fullFile;
|
|
if(!FindFile(_T("pump.dbf"), fullFile)) {
|
|
AfxMessageBox(_T("对不起,没有发现数据库文件!"));
|
|
return;
|
|
}
|
|
XDbfTable *pTable = db.Open(fullFile);
|
|
if(!pTable)
|
|
return;
|
|
CString csType, csSize, csQ, csHead, csOwner;
|
|
double nPower(0), nWeight(0), nH(0), nH1(0), nH2(0), nB1(0), nL3(0), nLength(0), nWidth(0);
|
|
double nDeep(0);
|
|
m_listCtrl.DeleteAllItems();
|
|
for(pTable->MoveFirst();!pTable->IsEOF();pTable->MoveNext()){
|
|
GET_FIELD(pTable, _T("Type"), csType);
|
|
GET_FIELD(pTable, _T("Pump_size"), csSize);
|
|
GET_FIELD(pTable, _T("Q"), csQ);
|
|
GET_FIELD(pTable, _T("Head"), csHead);
|
|
GET_FIELD(pTable, _T("Power"), nPower);
|
|
GET_FIELD(pTable, _T("Weight"), nWeight);
|
|
GET_FIELD(pTable, _T("Owner"), csOwner);
|
|
GET_FIELD(pTable, _T("H"), nH);
|
|
GET_FIELD(pTable, _T("H1"), nH1);
|
|
GET_FIELD(pTable, _T("H2"), nH2);
|
|
GET_FIELD(pTable, _T("L1"), nB1);
|
|
GET_FIELD(pTable, _T("L2"), nL3);
|
|
GET_FIELD(pTable, _T("Length"), nLength);
|
|
GET_FIELD(pTable, _T("Width"), nWidth);
|
|
GET_FIELD(pTable, _T("M"), nDeep);
|
|
if(_tcsicmp(csCurType, csType) == 0 && _tcsicmp(csCurFactory, csOwner) == 0){
|
|
int num = m_listCtrl.GetItemCount();
|
|
m_listCtrl.InsertItem ( num, csSize, 0 );
|
|
m_listCtrl.SetItemText ( num, 1, csQ);
|
|
m_listCtrl.SetItemText ( num, 2, csHead);
|
|
m_listCtrl.SetItemText ( num, 3, XString(_T("%.1f"), nPower));
|
|
m_listCtrl.SetItemText ( num, 4, XString(_T("%.1f"), nWeight));
|
|
m_listCtrl.SetItemText ( num, 5, XString(_T("%.1f"), nLength));
|
|
m_listCtrl.SetItemText ( num, 6, XString(_T("%.1f"), nWidth));
|
|
m_listCtrl.SetItemText ( num, 7, XString(_T("%.1f"), nH));
|
|
m_listCtrl.SetItemText ( num, 8, XString(_T("%.1f"), nH1));
|
|
m_listCtrl.SetItemText ( num, 9, XString(_T("%.1f"), nH2));
|
|
m_listCtrl.SetItemText ( num, 10, XString(_T("%.1f"), nB1));
|
|
m_listCtrl.SetItemText ( num, 11, XString(_T("%.1f"), nL3));
|
|
m_listCtrl.SetItemText ( num, 12, XString(_T("%.1f"), nDeep));
|
|
|
|
}
|
|
}
|
|
|
|
Invalidate();
|
|
UpdateWindow();
|
|
}
|
|
|
|
void SplitQ(const TCHAR*szQ, double &nMinQ, double &nMaxQ)
|
|
{
|
|
CString csTmp = szQ;
|
|
int idx = csTmp.Find(_T("-"));
|
|
if(idx < 0){
|
|
nMinQ = _tstof(csTmp);
|
|
return;
|
|
}
|
|
int len = csTmp.GetLength();
|
|
CString csLeft, csRight;
|
|
csLeft = csTmp.Left(idx);
|
|
nMinQ = _tstof(csLeft);
|
|
idx = csTmp.Find(_T("-"), idx+1);
|
|
csRight = csTmp.Right(len - idx - 1);
|
|
nMaxQ = _tstof(csRight);
|
|
|
|
if(nMinQ > nMaxQ){
|
|
double nTmp = nMaxQ;
|
|
nMaxQ = nMinQ;
|
|
nMinQ = nTmp;
|
|
}
|
|
}
|
|
|
|
void CSelectPumpDlg::OnOK()
|
|
{
|
|
UpdateData(TRUE);
|
|
if(m_nQ < 0.01 || m_nH < 0.01){
|
|
MessageBox(_T("请正确输入流量及扬程参数"));
|
|
return;
|
|
}
|
|
CodeBase db;
|
|
XString fullFile;
|
|
if(!FindFile(_T("pump.dbf"), fullFile)) {
|
|
AfxMessageBox(_T("对不起,没有发现pump.dbf文件!"));
|
|
return;
|
|
}
|
|
XDbfTable *pTable = db.Open(fullFile);
|
|
if(!pTable)
|
|
return;
|
|
CString csCurType = m_lstType[m_iPumpType];
|
|
m_listCtrl.DeleteAllItems();
|
|
for(pTable->MoveFirst();!pTable->IsEOF();pTable->MoveNext()){
|
|
CString csType, csSize, csQ, csHead, csOwner;
|
|
double nPower(0), nWeight(0), nH(0), nH1(0), nH2(0), nB1(0), nL3(0), nLength(0), nWidth(0);
|
|
double nMinQ(-1), nMaxQ(-1), nMinH(-1), nMaxH(-1);
|
|
double nDeep(0);
|
|
GET_FIELD(pTable, _T("Type"), csType);
|
|
GET_FIELD(pTable, _T("Pump_size"), csSize);
|
|
GET_FIELD(pTable, _T("Q"), csQ);
|
|
GET_FIELD(pTable, _T("Head"), csHead);
|
|
GET_FIELD(pTable, _T("Power"), nPower);
|
|
GET_FIELD(pTable, _T("Weight"), nWeight);
|
|
GET_FIELD(pTable, _T("Owner"), csOwner);
|
|
GET_FIELD(pTable, _T("H"), nH);
|
|
GET_FIELD(pTable, _T("H1"), nH1);
|
|
GET_FIELD(pTable, _T("H2"), nH2);
|
|
GET_FIELD(pTable, _T("L1"), nB1);
|
|
GET_FIELD(pTable, _T("L2"), nL3);
|
|
GET_FIELD(pTable, _T("Length"), nLength);
|
|
GET_FIELD(pTable, _T("Width"), nWidth);
|
|
GET_FIELD(pTable, _T("M"), nDeep);
|
|
|
|
|
|
if(csQ == _T("") || csHead == _T("") || csSize == _T(""))
|
|
continue;
|
|
if(_tcsicmp(csType, csCurType) != 0)
|
|
continue;
|
|
|
|
SplitQ(csQ, nMinQ, nMaxQ);
|
|
SplitQ(csHead, nMinH, nMaxH);
|
|
if((fabs(nMinQ - m_nQ) < 0.01 && fabs(nMinH - m_nH) < 0.01 && nMaxQ < 0 && nMaxH < 0) ||
|
|
(m_nQ > nMinQ && m_nQ < nMaxQ && m_nH > nMinH && m_nH < nMaxH)){
|
|
int num = m_listCtrl.GetItemCount();
|
|
m_listCtrl.InsertItem ( num, csSize, 0 );
|
|
m_listCtrl.SetItemText ( num, 1, csQ);
|
|
m_listCtrl.SetItemText ( num, 2, csHead);
|
|
m_listCtrl.SetItemText ( num, 3, XString(_T("%.1f"), nPower));
|
|
m_listCtrl.SetItemText ( num, 4, XString(_T("%.1f"), nWeight));
|
|
m_listCtrl.SetItemText ( num, 5, XString(_T("%.1f"), nLength));
|
|
m_listCtrl.SetItemText ( num, 6, XString(_T("%.1f"), nWidth));
|
|
m_listCtrl.SetItemText ( num, 7, XString(_T("%.1f"), nH));
|
|
m_listCtrl.SetItemText ( num, 8, XString(_T("%.1f"), nH1));
|
|
m_listCtrl.SetItemText ( num, 9, XString(_T("%.1f"), nH2));
|
|
m_listCtrl.SetItemText ( num, 10, XString(_T("%.1f"), nB1));
|
|
m_listCtrl.SetItemText ( num, 11, XString(_T("%.1f"), nL3));
|
|
m_listCtrl.SetItemText ( num, 12, XString(_T("%.1f"), nDeep));
|
|
|
|
}
|
|
}
|
|
if(m_listCtrl.GetItemCount() < 1)
|
|
MessageBox(_T("没有找到合适的水泵"));
|
|
}
|
|
|
|
void CSelectPumpDlg::OnPaint()
|
|
{
|
|
CPaintDC dc(this); // device context for painting
|
|
OpenSlide();
|
|
}
|
|
|
|
|
|
|
|
void CSelectPumpDlg::OnDblclkListPump(NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
*pResult = 0;
|
|
POSITION pos = m_listCtrl.GetFirstSelectedItemPosition();
|
|
int nItem = m_listCtrl.GetNextSelectedItem(pos);
|
|
if(nItem > -1){
|
|
CString csRasie = m_listCtrl.GetItemText(nItem, 2);
|
|
CString csQ = m_listCtrl.GetItemText(nItem, 1);
|
|
CString csH = m_listCtrl.GetItemText(nItem, 8);
|
|
CString csHeight = m_listCtrl.GetItemText(nItem, 7);
|
|
CString csWidth = m_listCtrl.GetItemText(nItem, 6);
|
|
CString csLength = m_listCtrl.GetItemText(nItem, 5);
|
|
CString csH2 = m_listCtrl.GetItemText(nItem, 9);
|
|
CString csB = m_listCtrl.GetItemText(nItem, 10);
|
|
CString csL = m_listCtrl.GetItemText(nItem, 11);
|
|
CString csSpec = m_listCtrl.GetItemText(nItem, 0);
|
|
CString csDeep = m_listCtrl.GetItemText(nItem, 12);
|
|
|
|
m_iWidth = _ttoi(csWidth);
|
|
m_iLenght = _ttoi(csLength);
|
|
CString csCurType = m_lstType[m_iPumpType];
|
|
m_csRetSpec = csCurType;
|
|
m_csRetPumpSpec = csSpec;
|
|
// zxl 2013.10.31 del
|
|
// if(csCurType == _T("DL"))
|
|
// m_iLenght = m_iWidth;
|
|
|
|
m_iHeight = _ttoi(csHeight);
|
|
m_nRetQ = _tstof(csQ);
|
|
m_nRetRaise = _tstof(csRasie);
|
|
m_nRetB1 = _tstof(csB);
|
|
m_nRetL2 = _tstof(csL);
|
|
m_nRetH2 = _tstof(csH2);
|
|
m_nRetH = _tstof(csH);
|
|
m_nRetH3 = _tstof(csH2);
|
|
m_nDeep = _tstof(csDeep);
|
|
// zxl 2013.10.31 del
|
|
// if(csCurType == _T("DL")) //双轮DL型号, 出水标高=L3
|
|
// m_nRetH3 = _tstof(csL);
|
|
// else if(csCurType == _T("FLG、FLGR") || csCurType == _T("KQL"))
|
|
// m_nRetH3 = m_nRetH; //熊猫和凯泉立式, 出水标高=进水标高
|
|
// else if(csCurType == _T("XBD-DN"))
|
|
// m_nRetH3 = m_nRetL2; //凯泉立式消防
|
|
}
|
|
|
|
CDialog::OnOK();
|
|
}
|