Files
envi-code/SourceCode/Code2026/tg_shs/shs_TwtCalc/CesspoolCalcDlg.cpp
T
gjm 164968b62e chore
把非utf8-bom编码的cpp/h文件改为 utf8 bom 编码, msvc识别utf8编码时,如果不是bom格式的,会使用当前cp_oem来解码.
2026-10-04 00:04:20 +08:00

240 lines
7.0 KiB
C++

// CesspoolCalcDlg.cpp : implementation file
//
#include "stdafx.h"
#include "CesspoolCalcDlg.h"
//#include "MostuseWaterCalcDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//#ifdef _WIN64
#include"TGAs.h"
//#endif
/////////////////////////////////////////////////////////////////////////////
// CCesspoolCalcDlg dialog
void CesspoolCalc()
{
// CTemporaryResourceOverride vTemp;
// CCesspoolCalcDlg dlg;
// dlg.DoModal();
}
CCesspoolCalcDlg::CCesspoolCalcDlg(CWnd* pParent /*=NULL*/)
: CDialog(CCesspoolCalcDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CCesspoolCalcDlg)
m_iAllPeple = 0;
m_iCapacity = 0;
m_iCyc = 2;
m_csPercent = _T("70");
m_iTime = 0;
m_nCoefficient = 0.8;
m_iPercentFresh = 95;
m_iPercentLater = 90;
m_nCapacity = 25;
m_csRet1 = _T("");
m_csRet2 = _T("");
m_csAllRet = _T("");
//}}AFX_DATA_INIT
m_bLookup = FALSE;
}
void CCesspoolCalcDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCesspoolCalcDlg)
DDX_Control(pDX, IDC_LIST_CALC, m_listCtrl);
DDX_Text(pDX, IDC_EDIT_ALLNUM, m_iAllPeple);
DDX_CBIndex(pDX, IDC_COMBO_CAPACITY, m_iCapacity);
DDX_CBIndex(pDX, IDC_COMBO_CYC, m_iCyc);
DDX_CBString(pDX, IDC_COMBO_PERCENT, m_csPercent);
DDX_CBIndex(pDX, IDC_COMBO_TIME, m_iTime);
DDX_Text(pDX, IDC_EDIT_COEFFICIENT, m_nCoefficient);
DDX_Text(pDX, IDC_EDIT_PERCENT_FRESH, m_iPercentFresh);
DDX_Text(pDX, IDC_EDIT_PERCENT_LATER, m_iPercentLater);
DDX_Text(pDX, IDC_EDIT_CAPACITY, m_nCapacity);
DDX_Text(pDX, IDC_STATIC_RET1, m_csRet1);
DDX_Text(pDX, IDC_STATIC_RET2, m_csRet2);
DDX_Text(pDX, IDC_STATIC_ALLRET, m_csAllRet);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCesspoolCalcDlg, CDialog)
//{{AFX_MSG_MAP(CCesspoolCalcDlg)
ON_BN_CLICKED(IDC_BUTTON_PERCENT, OnButtonPercent)
ON_BN_CLICKED(IDC_BUTTON_CAPACITY, OnButtonCapacity)
ON_BN_CLICKED(IDC_BUTTON_LOOKUP, OnButtonLookup)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCesspoolCalcDlg message handlers
BOOL CCesspoolCalcDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_listCtrl.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT);
m_listCtrl.InsertColumn ( 0, _T("名称"), LVCFMT_CENTER, 90 );
m_listCtrl.InsertColumn ( 1, _T("容积"), LVCFMT_CENTER, 70 );
m_listCtrl.InsertColumn ( 2, _T("长度"), LVCFMT_CENTER, 90 );
m_listCtrl.InsertColumn ( 3, _T("宽度"), LVCFMT_CENTER, 90 );
m_listCtrl.InsertColumn ( 4, _T("图集号"), LVCFMT_CENTER, 95 );
SetupPoolData(-1);
CRect rect;
this->GetWindowRect(&rect);
rect.bottom -= 150;
this->MoveWindow(&rect);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CCesspoolCalcDlg::SetupPoolData(double nV)
{
XString fullFile;
if(!FindFile(_T("pool.dbf"), fullFile)) {
MessageBox(_T("对不起,没有发现pool.dbf文件!"));
return;
}
CodeBase db;
db.read_only = 1;
XDbfTable *pTable = db.Open(fullFile);
if(!pTable)
return;
m_listCtrl.DeleteAllItems();
CString csName, csNumber;
double v, len, width;
int idx(0);
DList<SUseUnitData> lstUnit;
for(pTable->MoveFirst();!pTable->IsEOF();pTable->MoveNext()){
GET_FIELD(pTable, _T("A"), csName);
GET_FIELD(pTable, _T("B"), v);
GET_FIELD(pTable, _T("C"), len);
GET_FIELD(pTable, _T("D"), width);
GET_FIELD(pTable, _T("E"), csNumber);
if(v > nV && nV > 0){
SUseUnitData *pData = new SUseUnitData(csName, csNumber, 0, v, len, width);
lstUnit.Append(pData);
}
if(nV < 0){
m_listCtrl.InsertItem ( idx, csName, 0 );
m_listCtrl.SetItemText ( idx, 1, XString(_T("%.2f"), v));
m_listCtrl.SetItemText ( idx, 2, XString(_T("%.2f"), len));
m_listCtrl.SetItemText ( idx, 3, XString(_T("%.2f"), width));
m_listCtrl.SetItemText ( idx, 4, csNumber);
idx++;
}
}
if(lstUnit.Length() > 0){
lstUnit.QuickSort(SUseUnitData::SortByItem);
for(int i=0;i<lstUnit.Length();i++){
csName = lstUnit[i]->m_csName;
csNumber = lstUnit[i]->m_csUnit;
v = lstUnit[i]->m_nStdUse;
len = lstUnit[i]->m_nFactor;
width = lstUnit[i]->m_nTime;
m_listCtrl.InsertItem ( idx, csName, 0 );
m_listCtrl.SetItemText ( idx, 1, XString(_T("%.2f"), v));
m_listCtrl.SetItemText ( idx, 2, XString(_T("%.2f"), len));
m_listCtrl.SetItemText ( idx, 3, XString(_T("%.2f"), width));
m_listCtrl.SetItemText ( idx, 4, csNumber);
idx++;
if(idx == 5)
break;
}
}
}
//计算公式见:白手册 544页
void CCesspoolCalcDlg::OnOK()
{
UpdateData();
if(m_iAllPeple <= 0){
MessageBox(_T("请输入总人数!"));
return;
}
if(_tstof(m_csPercent) > 100){
MessageBox(_T("请输入实际使用人数/总人数 的百分比。"));
return;
}
double nRet1(0), nRet2(0), nRetAll(0);
int iTime;
if(m_iTime == 0)
iTime = 12;
else if(m_iTime == 1)
iTime = 24;
else
iTime = 36;
double nCapacity = m_iCapacity == 0 ? 0.4 : 0.7;
double nRealPeople = m_iAllPeple*(_tstof(m_csPercent)/100);
int iCyc;
if(m_iCyc == 0)
iCyc = 360;
else if(m_iCyc == 1)
iCyc = 270;
else if(m_iCyc == 2)
iCyc = 180;
else
iCyc = 90;
nRet1 = nRealPeople*m_nCapacity*iTime/24/1000;
double nPercentFresh = ((double)m_iPercentFresh)/100;
double nPercentLater = ((double)m_iPercentLater)/100;
nRet2 = nCapacity*nRealPeople*iCyc*(1-nPercentFresh)*m_nCoefficient*1.2;
nRet2 = nRet2 / (1 - nPercentLater)/1000;
m_csRet1.Format(_T("%.3f"), nRet1);
m_csRet2.Format(_T("%.3f"), nRet2);
nRetAll = nRet1 + nRet2;
m_csAllRet.Format(_T("%.3f"), nRetAll);
SetupPoolData(nRetAll);
UpdateData(FALSE);
}
void CCesspoolCalcDlg::OnButtonPercent()
{
AfxMessageBox(_T("实际使用卫生设备的人数与总人数的百分比(%)!\n\n1.医院,疗养院,幼儿园(有住宿) 100%\n2.住宅,集体宿舍,旅馆 70%\n3.办公楼,教学楼,工业企业生活间 40%\n4.公共食堂,影剧院,体育场和其他公共场所(按座位计)10%\n\n"));
}
void CCesspoolCalcDlg::OnButtonCapacity()
{
AfxMessageBox(_T("每人每天污泥量(L/人·d)!\n\n1.粪便污水单独排放 0.4\n2.粪便、生活废水合流制排水 0.7\n\n"));
}
void CCesspoolCalcDlg::OnButtonLookup()
{
m_bLookup = !m_bLookup;
CWnd *pWnd = GetDlgItem(IDC_BUTTON_LOOKUP);
CRect rect;
this->GetWindowRect(&rect);
if(!m_bLookup){
pWnd->SetWindowText(_T("查询↓"));
rect.bottom -= 150;
this->MoveWindow(&rect);
}
else{
pWnd->SetWindowText(_T("查询↑"));
rect.bottom += 150;
this->MoveWindow(&rect);
}
}