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

📄 msgdemoview.cpp

📁 symbian手机短信报警
💻 CPP
📖 第 1 页 / 共 2 页
字号:
		strId=m_List.GetItemText(nItem,0);  
		m_MsgSend.SetMsgListContent(strId);
	}
}

void CMsgDemoView::OnSeek() 
{
	// TODO: Add your command handler code here
	CSeekItemDlg dlg;
	int nItem;
	if(dlg.DoModal()==IDOK)
	{
		BOOL bExist=FALSE;
		CString strId,strNum,strbSend,strContent,strDes; 
		int nCount=m_List.GetItemCount();
		for(int i=0;i<nCount;i++)
		{
			strId=m_List.GetItemText(i,0);
			if(strId==dlg.m_Id)
			{
				bExist=TRUE;
				nItem=i;
				strContent=m_List.GetItemText(i,1);
				strNum=m_List.GetItemText(i,2);
				strbSend=m_List.GetItemText(i,3);
				strDes=m_List.GetItemText(i,4);
				break;
			}
		}
		if(!bExist)
			::AfxMessageBox("搜索完毕,没有找到符合条件的信息记录!");
		else
		{
			CEditMsgDlg dlg;
			dlg.strId=strId;
			dlg.strContent=strContent;
			dlg.strNum=strNum;
			dlg.strbSend=strbSend;
			dlg.strDes=strDes;
			if(dlg.DoModal()==IDOK)
			{
				BOOL bExist=FALSE;
				int nCount=m_List.GetItemCount();
				CString szTempId;
				for(int i=0;i<nCount;i++)
				{
					szTempId=m_List.GetItemText(i,0);
					if(szTempId==dlg.m_Id)
					{
						nItem=i;
						bExist=TRUE;
						break;
					}
				} 
				if(bExist)
				{
					m_List.SetItemText(nItem,0,dlg.m_Id);
					m_List.SetItemText(nItem,1,dlg.m_Content);
					m_List.SetItemText(nItem,2,dlg.m_Num);
					m_List.SetItemText(nItem,3,dlg.m_bSend);
					m_List.SetItemText(nItem,4,dlg.m_Des);
				}
				else 
					::AfxMessageBox("没有找到列队编号为“"+dlg.m_Id+"” 的消息,更新失败!"); 
			}
		}
	}
}

void CMsgDemoView::ReadIniFileVal()
{
	CIniFile IniFile;
	CString str,path;
	path=AfxGetApp()->m_pszHelpFilePath;
	str=AfxGetApp()->m_pszExeName; 
	path=path.Left(path.GetLength()-str.GetLength()-4); 
	IniFile.SetName("MsgList");
	IniFile.SetPath(path);
	BOOL bExist=IniFile.OpenIniFileForRead();
	if(bExist)
	{
		CString strId,strTolVal;
		for(int i=0;i<500;i++)
		{
			strId.Format("%.4d",i+1);
			strTolVal.Empty();
			IniFile.GetItemString("Data",strId,strTolVal);
			if(!strTolVal.IsEmpty())
				DataProcessIniVal(strTolVal,i+1);
		}
	}
}

void CMsgDemoView::DataProcessIniVal(CString strVal,int nLen)//进行处理,中间将;号内容分割开。
{
	CString szTemp;	
	szTemp=strVal;
	CString str[10]; 
	int nSize=1;
	while(1)
	{ 
		int nCount=szTemp.Find(';');
		if(nCount==-1)
			break;
		str[nSize]=szTemp.Left(nCount);
		szTemp=szTemp.Right(szTemp.GetLength()-nCount-1);			
		nSize++;
	} 
	str[nSize]=szTemp;
	//Insert ListCtrl Content
	int nPos=m_List.GetItemCount();
	if(!str[1].IsEmpty())
	{
		this->m_List.InsertItem(nPos,str[1]);
		this->m_List.SetItemText(nPos,1,str[2]);
		this->m_List.SetItemText(nPos,2,str[3]);
		this->m_List.SetItemText(nPos,3,str[4]); 
		this->m_List.SetItemText(nPos,4,str[5]);
	}
	//Reset the temp value
	m_strId[nLen]=str[1];
	m_strContent[nLen]=str[2];
	m_strNum[nLen]=str[3];
	m_strbSend[nLen]=str[4];
	m_strDes[nLen]=str[5];
}

void CMsgDemoView::OnRemoveAll() 
{
	// TODO: Add your command handler code here
	if(MessageBox("确定要删除所有信息列表记录吗?    ","询问信息",MB_OKCANCEL|MB_ICONQUESTION)==IDOK)
	{
		m_List.DeleteAllItems();
		for(int i=0;i<500;i++)
		{
			m_strId[i+1].Empty();
			m_strContent[i+1].Empty();
			m_strNum[i+1].Empty();
			m_strbSend[i+1].Empty();
			m_strDes[i+1].Empty();			
		}
		ResetIniFileVal();
	}
}



void CMsgDemoView::ResetIniFileVal()
{
	CIniFile IniFile;
	CString str,path;
	path=AfxGetApp()->m_pszHelpFilePath;
	str=AfxGetApp()->m_pszExeName; 
	path=path.Left(path.GetLength()-str.GetLength()-4); 
	IniFile.SetName("MsgList");
	IniFile.SetPath(path);
	BOOL bExist=IniFile.OpenIniFileForWrite();
	if(bExist)
	{
		IniFile.WriteSection("Data"); 
		for(int i=0;i<500;i++)
		{
			CString strId,strTolVal;
			strId.Format("%.4d",i+1);
			strTolVal=m_strId[i+1]+";"+m_strContent[i+1]+";"+m_strNum[i+1]+";"+m_strbSend[i+1]
				+";"+m_strDes[i+1];
			IniFile.WriteItemString(strId,strTolVal);
		}
	}
}







void CMsgDemoView::ConnectToDatabase()
{	
	HRESULT hr;
	try
	{
		hr = m_pConnection.CreateInstance("ADODB.Connection");//创建Connection对象
		if(SUCCEEDED(hr))
		{
			hr = m_pConnection->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=JHWY.mdb","","",adModeUnknown);///连接数据库
			///上面一句中连接字串中的Provider是针对ACCESS2000环境的,对于ACCESS97,需要改为:Provider=Microsoft.Jet.OLEDB.3.51; }
		} 
	}
	catch(_com_error e)///捕捉异常
	{
		CString errormessage;
		errormessage.Format("连接数据库失败!\r\n错误信息:%s",e.ErrorMessage());
		AfxMessageBox(errormessage);///显示错误信息
		exit(0);
	}  
	
	
	
	//read data from database and save to ini file
	_RecordsetPtr m_pRecordset;
	_variant_t RecordsAffected;
	m_pRecordset.CreateInstance(__uuidof(Recordset));
	m_pConnection->put_ConnectionTimeout(long(5));
	//	m_pRecordset =m_pConnection->Execute("select name from Realanaquantity where warn='warn'",
	//		&RecordsAffected,adCmdText);
	//模拟量表
	m_pRecordset->Open("select * from Realanaquantity where warn='warn'",// 查询DemoTable表中所有字段
		m_pConnection.GetInterfacePtr(),  // 获取库接库的IDispatch指针
		adOpenDynamic,
		adLockOptimistic,
		adCmdText); 
	int nCount=1;
	while(!m_pRecordset->adoEOF)
	{
		_variant_t var = m_pRecordset->GetCollect("ID");
		if(var.vt != VT_NULL)
			m_strId[nCount] = (LPCSTR)_bstr_t(var);
		var = m_pRecordset->GetCollect("name");
		if(var.vt != VT_NULL)
			m_strContent[nCount] = (LPCSTR)_bstr_t(var);
		nCount++;
		m_pRecordset->MoveNext();
	}
	m_pRecordset->Close(); 
	//电气量表
	m_pRecordset->Open("select * from Realelecquantity where warn='warn'",// 查询DemoTable表中所有字段
		m_pConnection.GetInterfacePtr(),  // 获取库接库的IDispatch指针
		adOpenDynamic,
		adLockOptimistic,
		adCmdText);  
	while(!m_pRecordset->adoEOF)
	{
		_variant_t var = m_pRecordset->GetCollect("ID");
		if(var.vt != VT_NULL)
			m_strId[nCount] = (LPCSTR)_bstr_t(var);
		var = m_pRecordset->GetCollect("name");
		if(var.vt != VT_NULL)
			m_strContent[nCount] = (LPCSTR)_bstr_t(var);
		nCount++;
		m_pRecordset->MoveNext();
	}
	m_pRecordset->Close();
	//开关量表
	m_pRecordset->Open("select * from Realswitchamount where Attribute='warn'",// 查询DemoTable表中所有字段
		m_pConnection.GetInterfacePtr(),  // 获取库接库的IDispatch指针
		adOpenDynamic,
		adLockOptimistic,
		adCmdText);  
	while(!m_pRecordset->adoEOF)
	{
		_variant_t var = m_pRecordset->GetCollect("ID");
		if(var.vt != VT_NULL)
			m_strId[nCount] = (LPCSTR)_bstr_t(var);
		var = m_pRecordset->GetCollect("name");
		if(var.vt != VT_NULL)
			m_strContent[nCount] = (LPCSTR)_bstr_t(var);
		nCount++;
		m_pRecordset->MoveNext();
	}
	m_pRecordset->Close();	
	m_pRecordset->Release();
	//设置保护单元报警
	//20型号
	m_strId[nCount]="200";
	m_strContent[nCount]="过流保护动作"; 
	m_strId[nCount+1]="201";
	m_strContent[nCount+1]="速断保护动作";
	m_strId[nCount+2]="202";
	m_strContent[nCount+2]="低周减载动作";
	m_strId[nCount+3]="203";
	m_strContent[nCount+3]="保护重合闸动作";
	m_strId[nCount+4]="204";
	m_strContent[nCount+4]="不对应重合闸动作";
	m_strId[nCount+5]="205";
	m_strContent[nCount+5]="合闸后加速跳";
	m_strId[nCount+6]="206";
	m_strContent[nCount+6]="控电消失";
	m_strId[nCount+7]="207";
	m_strContent[nCount+7]="过流后加速跳";
	//21型号
	nCount+=8;
	m_strId[nCount]="210";
	m_strContent[nCount]="方向过流保护动作"; 
	m_strId[nCount+1]="211";
	m_strContent[nCount+1]="限时方向速断保护动作";
	m_strId[nCount+2]="212";
	m_strContent[nCount+2]="控电消失";
	m_strId[nCount+3]="213";
	m_strContent[nCount+3]="瞬时方向速断保护动作";
	m_strId[nCount+4]="214";
	m_strContent[nCount+4]="保护重合闸动作";
	m_strId[nCount+5]="215";
	m_strContent[nCount+5]="压力闭锁";
	m_strId[nCount+6]="216";
	m_strContent[nCount+6]="合闸后加速跳";
	m_strId[nCount+7]="217";
	m_strContent[nCount+7]="未用"; 
	//40型号
	nCount+=8;
	m_strId[nCount]="400";
	m_strContent[nCount]="过流保护动作"; 
	m_strId[nCount+1]="401";
	m_strContent[nCount+1]="速断保护动作";
	m_strId[nCount+2]="402";
	m_strContent[nCount+2]="控电消失";
	m_strId[nCount+3]="403";
	m_strContent[nCount+3]="瞬未用";
	m_strId[nCount+4]="404";
	m_strContent[nCount+4]="未用";
	m_strId[nCount+5]="405";
	m_strContent[nCount+5]="未用";
	m_strId[nCount+6]="406";
	m_strContent[nCount+6]="未用";
	m_strId[nCount+7]="407";
	m_strContent[nCount+7]="未用";  
	//50型号
	nCount+=8;
	m_strId[nCount]="500";
	m_strContent[nCount]="未用"; 
	m_strId[nCount+1]="501";
	m_strContent[nCount+1]="A相I段电压回路断线";
	m_strId[nCount+2]="502";
	m_strContent[nCount+2]="B相I段电压回路断线";
	m_strId[nCount+3]="503";
	m_strContent[nCount+3]="C相I段电压回路断线";
	m_strId[nCount+4]="504";
	m_strContent[nCount+4]="A相II段电压回路断线";
	m_strId[nCount+5]="505";
	m_strContent[nCount+5]="B相II段电压回路断线";
	m_strId[nCount+6]="506";
	m_strContent[nCount+6]="C相II段电压回路断线";
	m_strId[nCount+7]="507";
	m_strContent[nCount+7]="+KM接地";  
	m_strId[nCount+8]="508";
	m_strContent[nCount+8]="-KM接地"; 
	m_strId[nCount+9]="509";
	m_strContent[nCount+9]="A相I段母线接地";
	m_strId[nCount+10]="5010";
	m_strContent[nCount+10]="B相I段母线接地";
	m_strId[nCount+11]="5011";
	m_strContent[nCount+11]="C相I段母线接地";
	m_strId[nCount+12]="5012";
	m_strContent[nCount+12]="A相II段母线接地";
	m_strId[nCount+13]="5013";
	m_strContent[nCount+13]="B相II段母线接地";
	m_strId[nCount+14]="5014";
	m_strContent[nCount+14]="C相II段母线接地";
	m_strId[nCount+15]="5015";
	m_strContent[nCount+15]="未用"; 
	//10型号
	nCount+=16;
	m_strId[nCount]="100";
	m_strContent[nCount]="差动保护动作"; 
	m_strId[nCount+1]="101";
	m_strContent[nCount+1]="差动速断动作";
	m_strId[nCount+2]="102";
	m_strContent[nCount+2]="压力闭锁";
	m_strId[nCount+3]="103";
	m_strContent[nCount+3]="压力异常";
	m_strId[nCount+4]="104";
	m_strContent[nCount+4]="未用";
	m_strId[nCount+5]="105";
	m_strContent[nCount+5]="控电消失";
	m_strId[nCount+6]="106";
	m_strContent[nCount+6]="未用";
	m_strId[nCount+7]="107";
	m_strContent[nCount+7]="未用";  
	//11型号
	nCount+=8;
	m_strId[nCount]="110";
	m_strContent[nCount]="过流保护动作"; 
	m_strId[nCount+1]="111";
	m_strContent[nCount+1]="本体重瓦斯动作";
	m_strId[nCount+2]="112";
	m_strContent[nCount+2]="有载重瓦斯动作";
	m_strId[nCount+3]="113";
	m_strContent[nCount+3]="本体轻瓦斯动作";
	m_strId[nCount+4]="114";
	m_strContent[nCount+4]="有载轻瓦斯动作";
	m_strId[nCount+5]="115";
	m_strContent[nCount+5]="过负荷";
	m_strId[nCount+6]="116";
	m_strContent[nCount+6]="超温";
	m_strId[nCount+7]="117";
	m_strContent[nCount+7]="未用";  
	//13型号
	nCount+=8;
	m_strId[nCount]="130";
	m_strContent[nCount]="过流保护动作"; 
	m_strId[nCount+1]="131";
	m_strContent[nCount+1]="本体重瓦斯动作";
	m_strId[nCount+2]="132";
	m_strContent[nCount+2]="有载重瓦斯动作";
	m_strId[nCount+3]="133";
	m_strContent[nCount+3]="本体轻瓦斯动作";
	m_strId[nCount+4]="134";
	m_strContent[nCount+4]="有载轻瓦斯动作";
	m_strId[nCount+5]="135";
	m_strContent[nCount+5]="过负荷";
	m_strId[nCount+6]="136";
	m_strContent[nCount+6]="超温";
	m_strId[nCount+7]="137";
	m_strContent[nCount+7]="未用";  
	//12型号
	nCount+=8;
	m_strId[nCount]="120";
	m_strContent[nCount]="过流保护动作"; 
	m_strId[nCount+1]="121";
	m_strContent[nCount+1]="速断保护动作";
	m_strId[nCount+2]="122";
	m_strContent[nCount+2]="本体重瓦斯动作";
	m_strId[nCount+3]="123";
	m_strContent[nCount+3]="有载重瓦斯动作";
	m_strId[nCount+4]="124";
	m_strContent[nCount+4]="本体轻瓦斯动作";
	m_strId[nCount+5]="125";
	m_strContent[nCount+5]="过负荷";
	m_strId[nCount+6]="126";
	m_strContent[nCount+6]="超高温";
	m_strId[nCount+7]="127";
	m_strContent[nCount+7]="未用"; 
	m_strId[nCount+8]="128";
	m_strContent[nCount+8]="未用"; 
	m_strId[nCount+9]="129";
	m_strContent[nCount+9]="未用";
	m_strId[nCount+10]="1210";
	m_strContent[nCount+10]="未用";
	m_strId[nCount+11]="1211";
	m_strContent[nCount+11]="未用";
	m_strId[nCount+12]="1212";
	m_strContent[nCount+12]="有载轻瓦斯动作";
	m_strId[nCount+13]="1213";
	m_strContent[nCount+13]="未用";
	m_strId[nCount+14]="1214";
	m_strContent[nCount+14]="超高温";
	m_strId[nCount+15]="1215";
	m_strContent[nCount+15]="未用";  
	//60型号
	nCount+=16;
	m_strId[nCount]="600";
	m_strContent[nCount]="差动保护动作"; 
	m_strId[nCount+1]="601";
	m_strContent[nCount+1]="差动速断动作";
	m_strId[nCount+2]="602";
	m_strContent[nCount+2]="压力闭锁";
	m_strId[nCount+3]="603";
	m_strContent[nCount+3]="压力异常";
	m_strId[nCount+4]="604";
	m_strContent[nCount+4]="未用";
	m_strId[nCount+5]="605";
	m_strContent[nCount+5]="控电消失";
	m_strId[nCount+6]="606";
	m_strContent[nCount+6]="未用";
	m_strId[nCount+7]="607";
	m_strContent[nCount+7]="未用";  
	//61型号
	nCount+=8;
	m_strId[nCount]="610";
	m_strContent[nCount]="过流保护动作"; 
	m_strId[nCount+1]="611";
	m_strContent[nCount+1]="过负荷";
	m_strId[nCount+2]="612";
	m_strContent[nCount+2]="过电压动作";
	m_strId[nCount+3]="613";
	m_strContent[nCount+3]="转子一点接地";
	m_strId[nCount+4]="614";
	m_strContent[nCount+4]="定子接地";
	m_strId[nCount+5]="615";
	m_strContent[nCount+5]="控电消失";
	m_strId[nCount+6]="616";
	m_strContent[nCount+6]="励磁熔断";
	m_strId[nCount+7]="617";
	m_strContent[nCount+7]="高压熔断";  
	//30型号
	nCount+=8;
	m_strId[nCount]="300";
	m_strContent[nCount]="过流保护动作"; 
	m_strId[nCount+1]="301";
	m_strContent[nCount+1]="速断保护动作";
	m_strId[nCount+2]="302";
	m_strContent[nCount+2]="欠压保护动作";
	m_strId[nCount+3]="303";
	m_strContent[nCount+3]="过压保护动作";
	m_strId[nCount+4]="304";
	m_strContent[nCount+4]="零序过电压";
	m_strId[nCount+5]="305";
	m_strContent[nCount+5]="零序过电流";
	m_strId[nCount+6]="306";
	m_strContent[nCount+6]="控电消失";
	m_strId[nCount+7]="307";
	m_strContent[nCount+7]="未用"; 
	ResetIniFileVal();
}



void CMsgDemoView::OnConfigReal() 
{
	// TODO: Add your command handler code here
	CConfigMsgDlg dlg;
	dlg.DoModal();
}





void CMsgDemoView::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	m_MsgSend.JudgeTimeToSendMsg();//判断进行发送
	CView::OnTimer(nIDEvent);
}

⌨️ 快捷键说明

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