www.pudn.com > GSMTest1.rar > StandDlg.cpp
// StandDlg.cpp : implementation file // #include "stdafx.h" #include "GSMTest.h" #include "StandDlg.h" #include "winsock.h" #include#include "database.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CStandDlg dialog CStandDlg::CStandDlg(CWnd* pParent /*=NULL*/) : CDialog(CStandDlg::IDD, pParent) { //{{AFX_DATA_INIT(CStandDlg) m_sCurA = _T(""); m_sCurB = _T(""); m_sCurC = _T(""); m_sFactor = _T(""); m_sTemp = _T(""); m_sVolA = _T(""); m_sVolB = _T(""); m_sVolC = _T(""); //}}AFX_DATA_INIT } void CStandDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CStandDlg) DDX_Control(pDX, IDC_DUTY_LIST, m_ctrDutyList); DDX_Text(pDX, IDC_CUR_A, m_sCurA); DDV_MaxChars(pDX, m_sCurA, 10); DDX_Text(pDX, IDC_CUR_B, m_sCurB); DDV_MaxChars(pDX, m_sCurB, 10); DDX_Text(pDX, IDC_CUR_C, m_sCurC); DDV_MaxChars(pDX, m_sCurC, 10); DDX_Text(pDX, IDC_POWER_FACTOR, m_sFactor); DDV_MaxChars(pDX, m_sFactor, 10); DDX_Text(pDX, IDC_TEMP, m_sTemp); DDV_MaxChars(pDX, m_sTemp, 10); DDX_Text(pDX, IDC_VOL_A, m_sVolA); DDV_MaxChars(pDX, m_sVolA, 10); DDX_Text(pDX, IDC_VOL_B, m_sVolB); DDV_MaxChars(pDX, m_sVolB, 10); DDX_Text(pDX, IDC_VOL_C, m_sVolC); DDV_MaxChars(pDX, m_sVolC, 10); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CStandDlg, CDialog) //{{AFX_MSG_MAP(CStandDlg) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CStandDlg message handlers BOOL CStandDlg::OnInitDialog() { CDialog::OnInitDialog(); m_ctrDutyList.InsertColumn(0,"编号",LVCFMT_CENTER,60,0); m_ctrDutyList.InsertColumn(1,"责任人",LVCFMT_CENTER,80,1); m_ctrDutyList.InsertColumn(2,"手机号码",LVCFMT_CENTER,120,2); m_ctrDutyList.InsertColumn(3,"备注",LVCFMT_CENTER,200,3); m_ctrDutyList.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|LVS_EX_SUBITEMIMAGES); ShowStandard(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CStandDlg::ShowStandard() { CDatabase database; if(!database.ConnectDB()) { AfxMessageBox("无法显示该变压器的设置标准!"); CDialog::OnOK(); } try { CString def; CString charset="set names gb2312;";//使之正常显示中文,或用set character_set_results=gb2312; database.ExecuteSQL(charset,charset.GetLength());//执行语句. Data_Param result; result.tab_name="trans_info"; result.select_exp="Ia,Ib,Ic,Ua,Ub,Uc,F,Temp"; def.Format("trans_id=%s",m_sTransID); result.where_def=def.GetBuffer(30); if(database.SelectRecord(&result)) { MYSQL_ROW row=database.GetRecord(); m_sCurA=row[0]; m_sCurB=row[1]; m_sCurC=row[2]; m_sVolA=row[3]; m_sVolB=row[4]; m_sVolC=row[5]; m_sFactor=row[6]; m_sTemp=row[7]; UpdateData(FALSE); } else { AfxMessageBox("无法显示该变压器的设置标准!"); CDialog::OnOK(); } result.tab_name="duty_info,trans_duty"; result.select_exp="id,duty_name,duty_tel,remark"; def.Format("trans_id=%s and duty_info.duty_id=trans_duty.duty_id",m_sTransID); result.where_def=def.GetBuffer(100); if(database.SelectRecord(&result)) { int count=(int)database.GetRowNum(); for(int i=0;i