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

📄 mhdialog.cpp

📁 实现规则推理 模糊识别 神经网络的专家系统
💻 CPP
字号:
// MHDialog.cpp : implementation file
//
#include "stdafx.h"
#include "AcquireKlg.h"
#include "AcquireKlgDoc.h"
#include "MainFrm.h"
#include "RuleDefineView.h"
#include "Global.h"
#include <math.h>

#include "MHDialog.h"


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

/////////////////////////////////////////////////////////////////////////////
// CMHDialog dialog
extern CADODatabase GlDataBase;

CMHDialog::CMHDialog(CWnd* pParent /*=NULL CWnd CDialog*/)
	:CDialog(CMHDialog::IDD, pParent)
{
	//{{AFX_DATA_INIT(CMHDialog)
//	m_pRdView = pParent;
	//}}AFX_DATA_INIT
}



void CMHDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CMHDialog)
	DDX_Control(pDX, IDC_EDIT_SensorW, m_sensorw);
	DDX_Control(pDX, IDC_EDIT_SensorSN, m_edit_sensorsn);
	DDX_Control(pDX, IDC_COMBO_SensorTP, m_combo_sensortp);
	DDX_Control(pDX, IDC_EDIT_FR_id, m_edit_FR_id);
	DDX_Control(pDX, IDC_ADODC1, m_adodc_cgqqk);
	DDX_Control(pDX, IDC_DATAGRID1, m_datagrid_cgqqk);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CMHDialog, CDialog)
	//{{AFX_MSG_MAP(CMHDialog)
	ON_BN_CLICKED(IDC_BUTTON_addcgq, OnBUTTONaddcgq)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMHDialog message handlers



BEGIN_EVENTSINK_MAP(CMHDialog, CDialog)
    //{{AFX_EVENTSINK_MAP(CMHDialog)
	//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()
//获得指定的视图类指针
CView* CMHDialog::GetView(CRuntimeClass* pClass) 
{ 
	CAcquireKlgDoc* pDoc=(CAcquireKlgDoc*)GetParentFrame()->GetActiveView()->GetDocument();
	ASSERT(pDoc);
	CView* pView = NULL; 
	POSITION pos=pDoc->GetFirstViewPosition(); 
	while(pos!=NULL){ 
		pView=pDoc->GetNextView(pos); 
		if(pView->IsKindOf(pClass)) 
			break;
	} 
	if(!pView->IsKindOf(pClass)){ 
		AfxMessageBox("Can't Locate the View."); 
		return NULL;
	} 
	return pView;
} 


void CMHDialog::OnBUTTONaddcgq() 
{	
//	m_pRdView->addcgq();
		CADORecordset recordset(&GlDataBase);
		CString strQuery;
		int nodenum = m_pNtView->GetNodeID();
		if(nodenum == ERR_NOSELETED) return;

		CString strFR_id, strSensorSN,strSensorTP,strSensorW;
		GetDlgItemText(IDC_EDIT_FR_id,strFR_id);
		GetDlgItemText(IDC_EDIT_SensorSN,strSensorSN);	
		GetDlgItemText(IDC_COMBO_SensorTP,strSensorTP);
		GetDlgItemText(IDC_EDIT_SensorW,strSensorW);
		
		strFR_id.TrimRight(); strSensorSN.TrimRight();strSensorTP.TrimRight();
		strSensorW.TrimRight();
		
		if(strFR_id.GetLength()==0||strSensorSN.GetLength()==0||
			strSensorTP.GetLength()==0||strSensorW.GetLength()==0){
			AfxMessageBox("请完整输入传感器情况信息!");
			return;
		}
				
			strQuery.Format("insert into Fuse_Sensor_Table(FR_id,SensorSN,SensorTP,SensorW) values(%d,%d,'%s',%f)",atoi(strFR_id.GetBuffer(0)),atoi(strSensorSN.GetBuffer(0)),strSensorTP,atof(strSensorW.GetBuffer(0)));
			recordset.SetQuery(strQuery);
			if(recordset.Open() == TRUE){
				AfxMessageBox("传感器情况信息插入成功!");
			}
	shownew();
	m_datagrid_cgqqk.Refresh();
	clearinput();
	
}

BOOL CMHDialog::OnInitDialog() 
{
	CDialog::OnInitDialog();
	m_pNtView = (CNodeTreeView*)GetView(RUNTIME_CLASS(CNodeTreeView));
	m_pRDView=(CRuleDefineView*)GetView(RUNTIME_CLASS(CRuleDefineView));
	//传感器类型
	CADORecordset recordset(&GlDataBase);
	CString str;
	recordset.SetQuery("select * from 条件元件表");
	recordset.Open();
	CString strelement;
	m_combo_sensortp.ResetContent();
	while(recordset.IsEof()!=TRUE){
		recordset.GetFieldValue("条件元内容",strelement);
		m_combo_sensortp.AddString(strelement);
		recordset.MoveNext();
	}

	//显示新记录
	shownew();
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
void CMHDialog::shownew() 
{

	CString xh=m_pRDView->m_cBlurMergePage.xh;
	SetDlgItemText(IDC_EDIT_FR_id,xh);

	m_adodc_cgqqk.SetConnectionString((LPCTSTR)"Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=TDESdb");
	m_adodc_cgqqk.SetCommandType(1);
	CString str;
	str.Format("select  FR_id 融合规则ID号,SensorSN 传感器序号,SensorTP 传感器类型,SensorW 传感器权重  from Fuse_Sensor_Table where FR_id=%d",atoi(xh.GetBuffer(0)));
	m_adodc_cgqqk.SetRecordSource(str);
	m_adodc_cgqqk.Refresh();
	
	return;  // 
}
void CMHDialog::clearinput() 
{
	SetDlgItemText(IDC_EDIT_SensorSN,"");
	SetDlgItemText(IDC_COMBO_SensorTP,"");
	SetDlgItemText(IDC_EDIT_SensorW,"");
}

⌨️ 快捷键说明

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