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

📄 dlgbkm.cpp

📁 电子监控的网络编程实例
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	}
	if (m_nCurrXH>0) {
		GetDlgItem(IDC_BTN_OPEN)->EnableWindow(true);		
	}else
	{
		GetDlgItem(IDC_Btn_Next)->EnableWindow(true);
	}	
	n_item=0;
	*/
	
}

void CDlgBkM::OnBtnNext() 
{
	// TODO: Add your control notification handler code here
	CVideoCaptureView* pView=CVideoCaptureView::GetView();
	if(!pView)
		return;

	if (!pRst->IsOpen() || pRst->GetRecordCount()<1) {
		return;
	}

	if (pRst->IsEof()) {
		AfxMessageBox("没有纪录向后翻!");
		pRst->MoveLast();
		return;
	}
	if (pRst->IsBof()) {
		pRst->MoveFirst();
	}
	
	m_list.DeleteAllItems();
	
	CString sSQL ;
	DWORD i=0;	
	try{	
		int ii=pRst->IsEof();		
		while (!pRst->IsEof() && !pRst->IsBof()) {
			i++;
			if (i>=MAXRECORD) {
				break;
			}
			pRst->GetFieldValue("HPHM",sSQL);
			n_item=m_list.InsertItem(0,sSQL);
			int HPYS=0;
			pRst->GetFieldValue("HPYS",HPYS);
			if (HPYS==0) {
				sSQL="蓝色";
			}else if (HPYS==1) {
				sSQL="黄色";
			}else if(HPYS==2){
				sSQL="白色";
			}else{
				sSQL="黑色";
			}
			m_list.SetItemText(n_item,1,sSQL);
			pRst->GetFieldValue("HPZL",sSQL);
			m_list.SetItemText(n_item, 2, sSQL);
			pRst->GetFieldValue("BKYY",sSQL);
			m_list.SetItemText(n_item, 3, sSQL);			
			pRst->GetFieldValue("BKSJ",sSQL);
			m_list.SetItemText(n_item, 4, sSQL);			
			pRst->GetFieldValue("BKDW",sSQL);
			m_list.SetItemText(n_item, 5, sSQL);			
			
			pRst->GetFieldValue("DEAL",sSQL);
			if (sSQL=="0") {
				m_list.SetItemText(n_item,6,"未处理");
			}else
			{
				m_list.SetItemText(n_item,6,"已处理");
			}
			
			pRst->GetFieldValue("CLRQ",sSQL);
			
			m_list.SetItemText(n_item,7,sSQL);
			
			pRst->MoveNext();
			
		}
		n_item=m_list.GetItemCount()-1;
		if (m_list.GetItemCount()>0) {
			SetAddWindow(0);
			m_list.EnsureVisible(m_list.GetItemCount()-1,true);
			m_list.SetHotItem(m_list.GetItemCount()-1);
		}
		
	}catch (...) {
//		AfxMessageBox("黑名单控制模块打开失败,请尝试关闭本窗口,再打开。");
	}
	/*
	//从黑名单列表中导入黑名单
	BK strBK;
	CString bkYY;
	BOOL bNext=false;
	DWORD nSum=pView->bkArray.GetSize();
	m_nCurrXH+=500;
	for(int i=m_nCurrXH,int k=0;i<m_nCurrXH+500;i++,k++){
		if (i<nSum) {
			try{
				strBK=pView->bkArray.GetAt(i);
				int p=m_list.InsertItem(k,strBK.sHPHM);
				bkYY=pView->Array_FindInBKYYList(strBK.nBKYY);				
				m_list.SetItemText(p,3,bkYY);				
				bNext=true;
			}catch (...) {
			}
			
		}else
		{				
			bNext=false;
			break;
		}
	}
	

	if (bNext) {	
		GetDlgItem(IDC_Btn_Next)->EnableWindow(true);
	}else{
		GetDlgItem(IDC_Btn_Next)->EnableWindow(false);	
	}
	
	GetDlgItem(IDC_BTN_OPEN)->EnableWindow(true);
	*/

}

void CDlgBkM::OnButtonFirst() 
{
	CVideoCaptureView* pView=CVideoCaptureView::GetView();
	if(!pView)
		return;
	
	if (!pRst->IsOpen() || pRst->GetRecordCount()<1) {
		return;
	}
	pRst->MoveFirst();
	

	m_list.DeleteAllItems();
	CString sSQL ;
	DWORD i=0;	
	try{	
		
		while (!pRst->IsEof() && !pRst->IsBof()) {
			
			i++;
			if (i>=MAXRECORD) {				
				break;
			}
			pRst->GetFieldValue("HPHM",sSQL);
			n_item=m_list.InsertItem(0,sSQL);
			int HPYS=0;
			pRst->GetFieldValue("HPYS",HPYS);
			if (HPYS==0) {
				sSQL="蓝色";
			}else if (HPYS==1) {
				sSQL="黄色";
			}else if(HPYS==2){
				sSQL="白色";
			}else{
				sSQL="黑色";
			}
			m_list.SetItemText(n_item,1,sSQL);
			pRst->GetFieldValue("HPZL",sSQL);
			m_list.SetItemText(n_item, 2, sSQL);
			pRst->GetFieldValue("BKYY",sSQL);
			m_list.SetItemText(n_item, 3, sSQL);			
			pRst->GetFieldValue("BKSJ",sSQL);
			m_list.SetItemText(n_item, 4, sSQL);			
			pRst->GetFieldValue("BKDW",sSQL);
			m_list.SetItemText(n_item, 5, sSQL);			
			
			pRst->GetFieldValue("DEAL",sSQL);
			if (sSQL=="0") {
				m_list.SetItemText(n_item,6,"未处理");
			}else
			{
				m_list.SetItemText(n_item,6,"已处理");
			}
			
			pRst->GetFieldValue("CLRQ",sSQL);
			
			m_list.SetItemText(n_item,7,sSQL);	
			pRst->MoveNext();
			
		}
		n_item=m_list.GetItemCount()-1;
		if (m_list.GetItemCount()>0) {
			SetAddWindow(0);
			m_list.EnsureVisible(m_list.GetItemCount()-1,true);
			m_list.SetHotItem(m_list.GetItemCount()-1);
		}
		
	}catch (...) {
		//		AfxMessageBox("黑名单控制模块打开失败,请尝试关闭本窗口,再打开。");
	}	// TODO: Add your control notification handler code here
	
}

void CDlgBkM::OnButtonLast() 
{
	CVideoCaptureView* pView=CVideoCaptureView::GetView();
	if(!pView)
		return;
	
	if (!pRst->IsOpen() || pRst->GetRecordCount()<1) {
		return;
	}
	pRst->MoveLast();
	
	m_list.DeleteAllItems();
	CString sSQL ;
	DWORD i=0;	
	try{	
		
		while (!pRst->IsEof() && !pRst->IsBof()) {
			
			i++;
			if (i>=MAXRECORD) {				
				break;
			}
			pRst->GetFieldValue("HPHM",sSQL);
			n_item=m_list.InsertItem(0,sSQL);
			int HPYS=0;
			pRst->GetFieldValue("HPYS",HPYS);
			if (HPYS==0) {
				sSQL="蓝色";
			}else if (HPYS==1) {
				sSQL="黄色";
			}else if(HPYS==2){
				sSQL="白色";
			}else{
				sSQL="黑色";
			}
			m_list.SetItemText(n_item,1,sSQL);
			pRst->GetFieldValue("HPZL",sSQL);
			m_list.SetItemText(n_item, 2, sSQL);
			pRst->GetFieldValue("BKYY",sSQL);
			m_list.SetItemText(n_item, 3, sSQL);			
			pRst->GetFieldValue("BKSJ",sSQL);
			m_list.SetItemText(n_item, 4, sSQL);			
			pRst->GetFieldValue("BKDW",sSQL);
			m_list.SetItemText(n_item, 5, sSQL);			
			
			pRst->GetFieldValue("DEAL",sSQL);
			if (sSQL=="0") {
				m_list.SetItemText(n_item,6,"未处理");
			}else
			{
				m_list.SetItemText(n_item,6,"已处理");
			}
			
			pRst->GetFieldValue("CLRQ",sSQL);
			
			m_list.SetItemText(n_item,7,sSQL);	
			
			pRst->MovePrevious();
			
		}
		n_item=m_list.GetItemCount()-1;
		if (m_list.GetItemCount()>0) {
			SetAddWindow(0);
			m_list.EnsureVisible(m_list.GetItemCount()-1,true);
			m_list.SetHotItem(m_list.GetItemCount()-1);
		}
		
	}catch (...) {
		//		AfxMessageBox("黑名单控制模块打开失败,请尝试关闭本窗口,再打开。");
	}	
}

void CDlgBkM::OnButtonOk() 
{
	// TODO: Add your control notification handler code here
	CVideoCaptureView* pView=CVideoCaptureView::GetView();
	if(!pView)
		return ;
	UpdateData();
	BOOL  bAdd=FALSE;
	CString sTitle;
	GetDlgItem(IDC_BUTTON_OK)->GetWindowText(sTitle);
	if (sTitle.Find("加",0)>-1) {
		bAdd=TRUE;
	}

	CString ss;
	CADODataset *pRst1=new CADODataset();
	
	ss.Format("select * from WZBK where HPHM='%s'",m_strHPBH);
	pRst1->SetConnection(pView->pConn);
	pRst1->Open(ss,CADODataset::openQuery);
	if(!pRst1->IsEof())
	{
		if (bAdd) {
			ShowMessage("该嫌疑车辆已经存在!");
			pRst1->Close();
			delete pRst1;
			return;
		}
	}
	if(pRst1->IsEof()){
		if (!bAdd) {
			ShowMessage("该嫌疑车辆已被删除,无法修改!");				
			pRst1->Close();
			m_list.DeleteItem(n_item);
			delete pRst1;
			return;
		}

	}
	pRst1->Close();
	delete pRst1;
	
	CString sql;	
	CString HPZL;
	if(m_strHPZL.GetLength()>1)
	{
		HPZL=m_strHPZL.Left(2);
		try
		{
			int hh=atoi(HPZL);
		}
		catch (...) {
			HPZL="24";
		}
	}
	else
		HPZL="24";
	CString BKSJ=m_tmBKSJ.Format("%Y-%m-%d %H:%M:%S");
	int HPYS=0;
	if (m_strHPYS=="黄色")
		HPYS=1;
	else if(m_strHPYS=="白色")
		HPYS=2;
	else if(m_strHPYS=="黑色")
		HPYS=3;
	
	CString sBKHM;
	int len;
	if(m_strHPBH.GetLength()<5)
		len=m_strHPBH.GetLength();
	else
		len=5;
	sBKHM=m_strHPBH.Right(len);
	
	if (bAdd) {
		sql.Format("insert into WZBK(HPHM, BKYY, BKSJ, BKDW, HPZL, HPYS,deal) values('%s', '%s', '%s', '%s', '%s',%d,'0')",m_strHPBH,m_strBKYY,BKSJ,m_strBKDW,HPZL,HPYS);
		n_item=m_list.InsertItem(0,m_strHPBH);
	}else{
		sql.Format("update WZBK  set BKYY='%s', BKSJ=CDATE('%s'), BKDW='%s', HPZL='%s', HPYS=%d where hphm='%s'",m_strBKYY,BKSJ,m_strBKDW,HPZL,HPYS,m_strHPBH);
	}
	try{
		pView->pConn->Execute(sql);
	}catch (...) {
		AfxMessageBox("数据保存失败");
		return;
	}
	
	
	m_list.SetItemText(n_item,1,m_strHPYS);
	m_list.SetItemText(n_item, 2,m_strHPZL);
	m_list.SetItemText(n_item, 3, m_strBKYY);
	m_list.SetItemText(n_item, 4,BKSJ);
	m_list.SetItemText(n_item, 5,m_strBKDW);
	if (bAdd) {
		m_list.SetItemText(n_item,6,"未处理");
	}
	
	m_list.SetItemText(n_item,7,"");
	
	m_list.EnsureVisible(n_item,true);
	m_list.SetHotItem(n_item);
	
	
	BK pBK;
	try{	
		
		int i=m_ctlBKYY.FindString(0,m_strBKYY);
		pBK.nBKYY=m_ctlBKYY.GetItemData(i);//
		
		memset(pBK.sBKHM,0,sizeof(pBK.sBKHM));
		memcpy(pBK.sBKHM,sBKHM.GetBuffer(0),len);//
		pBK.sBKHM[len]='\0';
		
		memset(pBK.sHPHM,0,sizeof(pBK.sHPHM));
		memcpy(pBK.sHPHM,m_strHPBH.GetBuffer(0),m_strHPBH.GetLength());//
		pBK.sHPHM[m_strHPBH.GetLength()]='\0';
		if (bAdd) {
			pView->Array_AddToBKList(pBK);
		}else{
			pView->Array_EditBKList(0,pBK);
		}
		
	}catch (...) {
	}

	SetAddWindow(0);//look

}

bool CDlgBkM::SetAddWindow(INT bAdd)//1,ADD,0,LOOK,2,EDIT
{
	switch(bAdd) {
	case 1:
		GetDlgItem(IDC_EDIT_HPBH)->EnableWindow(TRUE);
		GetDlgItem(IDC_COMBO_HPYS)->EnableWindow(TRUE);
		GetDlgItem(IDC_COMBO_HPZL)->EnableWindow(TRUE);
		GetDlgItem(IDC_DP_BKSJ)->EnableWindow(TRUE);
		GetDlgItem(IDC_COMBO_BKYY)->EnableWindow(TRUE);
		GetDlgItem(IDC_COMBO_BKDW)->EnableWindow(TRUE);
		
		GetDlgItem(IDC_BUTTON_OK)->SetWindowText("确认添加");
		GetDlgItem(IDC_BUTTON_OK)->ShowWindow(SW_NORMAL);	
		
		m_tmBKSJ=COleDateTime::GetCurrentTime();
		
		TCHAR sValue[MAX_PATH];
		GetPrivateProfileString("system","localcode","苏B",sValue,MAX_PATH,".\\config.ini");		
		m_strHPBH=sValue;
		UpdateData(FALSE);
		GetDlgItem(IDC_EDIT_HPBH)->SetFocus();
		

		break;
	case 2:
		GetDlgItem(IDC_EDIT_HPBH)->EnableWindow(FALSE);	
		GetDlgItem(IDC_COMBO_HPYS)->EnableWindow(TRUE);
		GetDlgItem(IDC_COMBO_HPZL)->EnableWindow(TRUE);
		GetDlgItem(IDC_DP_BKSJ)->EnableWindow(TRUE);
		GetDlgItem(IDC_COMBO_BKYY)->EnableWindow(TRUE);
		GetDlgItem(IDC_COMBO_BKDW)->EnableWindow(TRUE);
		
		GetDlgItem(IDC_BUTTON_OK)->SetWindowText("确认修改");
		GetDlgItem(IDC_BUTTON_OK)->ShowWindow(SW_NORMAL);
		break;
	default:
		GetDlgItem(IDC_EDIT_HPBH)->EnableWindow(FALSE);	
		GetDlgItem(IDC_COMBO_HPYS)->EnableWindow(FALSE);
		GetDlgItem(IDC_COMBO_HPZL)->EnableWindow(FALSE);
		GetDlgItem(IDC_DP_BKSJ)->EnableWindow(FALSE);
		GetDlgItem(IDC_COMBO_BKYY)->EnableWindow(FALSE);
		GetDlgItem(IDC_COMBO_BKDW)->EnableWindow(FALSE);
		GetDlgItem(IDC_BUTTON_OK)->ShowWindow(SW_HIDE);
		
		COleDateTime tm;
		CString BKSJ=m_list.GetItemText(n_item,4);
		int year=2004,month=9,day=10,minute=10,hour=10,second=10;
		if(BKSJ.GetLength()!=19)
		{
			tm=COleDateTime::GetCurrentTime();
		}
		else
		{			
			try
			{				
				tm.ParseDateTime(BKSJ);
			}
			catch (...) {
				tm=COleDateTime::GetCurrentTime();
			}
		}
		
		m_tmBKSJ=tm;
		m_strBKDW=m_list.GetItemText(n_item,4);
		m_strBKYY=m_list.GetItemText(n_item,3);
		m_strHPBH=m_list.GetItemText(n_item,0);
		m_strHPYS=m_list.GetItemText(n_item,1);
		m_strHPZL=m_list.GetItemText(n_item,2);		
		
		
	}
	UpdateData(FALSE);
	
	return TRUE;
	
}

void CDlgBkM::OnButtonP1() 
{
	
	if (m_list.GetItemCount()<1) {
		return;
	}
	n_item--;
	if (n_item<0) {
		n_item=0;
	}
	SetAddWindow(0);
	m_list.EnsureVisible(n_item,true);
	m_list.SetHotItem(n_item);

}

void CDlgBkM::OnButtonN1() 
{
	if (m_list.GetItemCount()<1) {
		return;
	}
	n_item++;
	if (n_item>=m_list.GetItemCount()) {
		n_item=m_list.GetItemCount()-1;
	}
	SetAddWindow(0);
	m_list.EnsureVisible(n_item,true);
	m_list.SetHotItem(n_item);
}

void CDlgBkM::OnButtonF1() 
{
	if (m_list.GetItemCount()<1) {
		return;
	}
	n_item=0;
	SetAddWindow(0);
	m_list.EnsureVisible(n_item,true);
	m_list.SetHotItem(n_item);
}

void CDlgBkM::OnButtonL1() 
{
	if (m_list.GetItemCount()<1) {
		return;
	}
	n_item=m_list.GetItemCount()-1;
	SetAddWindow(0);
	m_list.EnsureVisible(n_item,true);
	m_list.SetHotItem(n_item);
}

⌨️ 快捷键说明

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