Files
envi-code/SourceCode/Code2026/PipelineCmd/KTMediumDlg.cpp
T
2026-09-28 15:28:50 +08:00

202 lines
4.6 KiB
C++

#include "stdafx.h"
#include "KTMediumDlg.h"
#include "TJJZDlg.h"
#include "KTModelLayoutXData.h"
#include "CoreTools.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#ifndef WM_SHOWPARAMTEXT
#define WM_SHOWPARAMTEXT (WM_USER + 0x1001)
#endif
KTMediumDlg::KTMediumDlg(CWnd* pParent /*=NULL*/)
: CDialog(KTMediumDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(KTMediumDlg)
//}}AFX_DATA_INIT
m_pPipePar = NULL;
m_pADOServer = NULL;
}
void KTMediumDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(KTMediumDlg)
DDX_Control(pDX, IDC_LISTPREESS, m_wndPressList);
DDX_Control(pDX, IDC_MEDIUMLIST, m_wndListCtrl);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(KTMediumDlg, CDialog)
//{{AFX_MSG_MAP(KTMediumDlg)
ON_NOTIFY(NM_CLICK, IDC_MEDIUMLIST, OnClickMediumlist)
ON_LBN_SELCHANGE(IDC_LISTPREESS, OnSelchangeListpreess)
ON_BN_CLICKED(IDC_BTCUSTMOR, OnBtcustmor)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void KTMediumDlg::SetADOServer(KTADODatabase* pADOServer)
{
m_pADOServer = pADOServer;
}
BOOL KTMediumDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_ImageList.Create(IDB_BITMAPPIPE,16,1,ILC_COLOR16);
m_wndListCtrl.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT);
m_wndListCtrl.SetImageList(&m_ImageList,LVSIL_SMALL);
m_wndListCtrl.InsertColumn(0,_T("介质"),LVCFMT_LEFT,60,100);
m_wndListCtrl.InsertColumn(1,_T("描述"),LVCFMT_LEFT,240,100);
InitMediumFromDb();
InitPressFromDb();
return TRUE;
}
void KTMediumDlg::UpdateParamDlgFromParam()
{
InitMediumFromDb();
InitPressFromDb();
}
BOOL KTMediumDlg::OnCommand(WPARAM wParam, LPARAM lParam)
{
return CDialog::OnCommand(wParam, lParam);
}
BOOL KTMediumDlg::InitMediumFromDb()
{
if (m_pADOServer != NULL)
{
m_wndListCtrl.DeleteAllItems();
int nSel = 0;
//1。介质描述
KTValueTable table;
CString sSQL,sText,sDescr;
sSQL = _T("select [介质代号],[介质] from AecFluid order by ID");
m_pADOServer->GetSelData(sSQL,table);
int nCount = table.GetTableLogicSize();
int i = 0,nSize = 0;
CStringArray arValue;
for(i = 0;i<nCount;i++)
{
arValue.RemoveAll();
table.GetValueRecord(i,arValue);
nSize = arValue.GetSize();
ASSERT(nSize == 2);
sText = arValue.GetAt(0);
sDescr= arValue.GetAt(1);
this->m_wndListCtrl.InsertItem(i,sText,0);
this->m_wndListCtrl.SetItemText(i,1,sDescr);
if (sText.CompareNoCase(m_pPipePar->szMedia) == 0)
{
nSel = i;
}
}
this->m_wndListCtrl.SetItemState(nSel,LVIS_SELECTED,LVIS_SELECTED);
m_wndListCtrl.EnsureVisible(nSel,FALSE);
return TRUE;
}
return FALSE;
}
void KTMediumDlg::OnClickMediumlist(NMHDR* pNMHDR, LRESULT* pResult)
{
POSITION ps = m_wndListCtrl.GetFirstSelectedItemPosition();
if (ps != NULL)
{
int nItem = m_wndListCtrl.GetNextSelectedItem(ps);
if (nItem != -1)
{
CString sMedia = m_wndListCtrl.GetItemText(nItem,0);
CString sDescr = m_wndListCtrl.GetItemText(nItem,1);
_tcscpy(m_pPipePar->szMedia,sMedia);
_tcscpy(m_pPipePar->szDescr,sDescr);
GetParent()->GetParent()->SendMessage(WM_SHOWPARAMTEXT);
}
}
*pResult = 0;
}
void KTMediumDlg::InitPressFromDb()
{
//获取项目名称
CString sProject(CoreTools::GetCurrentProject());
CString sSQL;
sSQL.Format(_T("select [等级名称] from AecSpecname where [项目名称]='%s'"),sProject);
CStringArray arValues;
m_pADOServer->GetSelData(sSQL,arValues);
m_wndPressList.ResetContent();
for (int i = 0;i < arValues.GetSize();i++)
{
m_wndPressList.InsertString(i,arValues.GetAt(i));
}
int nIndex = m_wndPressList.FindString(0,m_pPipePar->szLevel);
if (nIndex != -1)
{
m_wndPressList.SetCurSel(nIndex);
}
}
void KTMediumDlg::OnSelchangeListpreess()
{
int nSel = m_wndPressList.GetCurSel();
if (nSel != -1)
{
CString sText;
m_wndPressList.GetText(nSel,sText);
_tcscpy(m_pPipePar->szLevel,sText);
GetParent()->GetParent()->SendMessage(WM_SHOWPARAMTEXT);
}
}
void KTMediumDlg::OnBtcustmor()
{
//select [介质代号],[介质] from KTFluid order by ID
CTJJZDlg dlg;
if (IDOK == dlg.DoModal())
{
CString sSQL;
sSQL.Format(_T("select [介质代号],[介质] from AecFluid"));
CStringList lstVals;
m_pADOServer->GetSelData(sSQL,lstVals);
if ( lstVals.Find(dlg.m_sMedia) != NULL ||
lstVals.Find(dlg.m_sDesc) != NULL )
{
AfxMessageBox(_T("输入的介质代号和介质已经存在!"));
return;
}
sSQL.Format(_T("insert into AecFluid ([行业],[介质代号],[介质]) values ('化工','%s','%s')"),dlg.m_sMedia,dlg.m_sDesc);
m_pADOServer->ExecuteSQL(sSQL);
int i = m_wndListCtrl.GetItemCount();
m_wndListCtrl.InsertItem(i,dlg.m_sMedia,0);
m_wndListCtrl.SetItemText(i,1,dlg.m_sDesc);
}
}