⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 msgseldlg.cpp

📁 电力监控系统。 使用VC实现
💻 CPP
字号:
// MsgSelDlg.cpp : implementation file
//

#include "stdafx.h"
#include "CurverDemo.h"
#include "MsgSelDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMsgSelDlg dialog


CMsgSelDlg::CMsgSelDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CMsgSelDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CMsgSelDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CMsgSelDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CMsgSelDlg)
	DDX_Control(pDX, IDC_YEAR, m_Year);
	DDX_Control(pDX, IDC_MONTH, m_Month);
	DDX_Control(pDX, IDC_DAY, m_Day);
	DDX_Control(pDX, IDC_MSG_SEL, m_MsgList);
	DDX_Control(pDX, IDC_RADIO1, m_SelId);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CMsgSelDlg, CDialog)
	//{{AFX_MSG_MAP(CMsgSelDlg)
	ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
	ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMsgSelDlg message handlers

BOOL CMsgSelDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	bAnalog = FALSE;
	db.Open("JHWY");
	this->m_SelId.SetCheck(TRUE);
	CTime Tm = CTime::GetCurrentTime();
	CString szYear,szMonth,szDay;
	szYear.Format("%.4d",Tm.GetYear());
	szMonth.Format("%.2d",Tm.GetMonth());
	szDay.Format("%.2d",Tm.GetDay());
	this->m_Year.SetWindowText(szYear);
	this->m_Month.SetWindowText(szMonth);
	this->m_Day.SetWindowText(szDay);
	SelElePoint();

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CMsgSelDlg::SelAnalogPoint()
{
	CRecordset res(&db);
	CString sql;
    CDBVariant var;
	var.Clear();
	CString szId; 
	this->m_MsgList.ResetContent();
	sql.Format("Select * From Realanaquantity");
	res.Open(CRecordset::forwardOnly,sql,CRecordset::readOnly);
    while(!res.IsEOF())
	{
		res.GetFieldValue("name",var);
		if(*var.m_pstring != "undefine") 
			this->m_MsgList.AddString(*var.m_pstring); 
		res.MoveNext();
	}
	res.Close();
}

void CMsgSelDlg::SelElePoint()//电气量
{
	CRecordset res(&db);
	CString sql;
    CDBVariant var;
	var.Clear();
	CString szId; 
	this->m_MsgList.ResetContent();
	sql.Format("Select * From Realelecquantity");
	res.Open(CRecordset::forwardOnly,sql,CRecordset::readOnly);
    while(!res.IsEOF())
	{
		res.GetFieldValue("name",var);
		if(*var.m_pstring != "undefine") 
			this->m_MsgList.AddString(*var.m_pstring); 
		res.MoveNext();
	}
	res.Close();
}

void CMsgSelDlg::OnRadio1() 
{
	// TODO: Add your control notification handler code here
	bAnalog = FALSE;
	SelElePoint();//电气量
}

void CMsgSelDlg::OnRadio2() 
{
	// TODO: Add your control notification handler code here
	SelAnalogPoint();
	bAnalog = TRUE;
}

void CMsgSelDlg::OnOK() 
{
	// TODO: Add extra validation here
	CString strYear,strMonth,strDay,strName;
	this->m_Day.GetWindowText(strDay);
	this->m_Month.GetWindowText(strMonth);
	this->m_Year.GetWindowText(strYear);
	this->m_MsgList.GetWindowText(strName);
	if(!strYear.IsEmpty() && !strMonth.IsEmpty() && !strYear.IsEmpty() &&!strName.IsEmpty())
	{
		CRecordset res(&db);
		CString sql;
		CDBVariant var;
		var.Clear();  
		if(!bAnalog)
			sql.Format("Select * From Realelecquantity where name = '%s'",strName);
		else
			sql.Format("Select * From Realanaquantity where name = '%s'",strName);
		res.Open(CRecordset::forwardOnly,sql,CRecordset::readOnly); 
		res.GetFieldValue("ID",var); 
		szName = strName;
		szId = *var.m_pstring;
		this->szYear = strYear;
		this->szMonth = strMonth;
		this->szDay = strDay;
		res.Close();
		CDialog::OnOK();
	}
	else
		::AfxMessageBox("信息选择不完整!");
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -