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

📄 handlg.cpp

📁 Vc++管理系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	_snprintf(dtstry,sizeof(dtstry),"%d%02d%02d",t.GetYear()+1,t.GetMonth(),t.GetDay());

	int	   i=m_listhand.GetSelectionMark();
	if(i==-1)
	{
		MessageBox("请选择一条记录!");
	}
	else
	{
		m_sbxgdlg.m_no	= m_listhand.GetItemText(i,1);
		m_sbxgdlg.m_stw	= m_listhand.GetItemText(i,2);
		m_sbxgdlg.m_fw	= m_listhand.GetItemText(i,3);
		m_sbxgdlg.m_fp	= m_listhand.GetItemText(i,4);
		m_sbxgdlg.m_jp	= m_listhand.GetItemText(i,5);
		m_sbxgdlg.m_sxh	= m_listhand.GetItemText(i,6);
		m_sbxgdlg.m_gl	= m_listhand.GetItemText(i,7);
		m_sbxgdlg.m_jsm	= m_listhand.GetItemText(i,8);
		//UpdateData(FALSE);

		if(m_sbxgdlg.DoModal()!=IDOK)
		{
			return;
		}

		int			keyid=atoi(m_listhand.GetItemText(i,0));
		CHandSet2	m_set;
	

		try
		{
			if(m_set.IsOpen())
				m_set.Close();
		
			m_set.m_strFilter.Format("num='%s' order by ID ASC",m_sbxgdlg.m_no.operator LPCTSTR());
		
		//	m_set.m_strFilter.Format("select * from BusMa where num like 'keyid'");
			m_set.Open(CRecordset::snapshot,NULL,CRecordset::none);
			
			if(m_set.IsOpen()&&!m_set.IsEOF())
			{
				m_set.Edit();
				m_set.m_Sdw		= m_sbxgdlg.m_stw;
				m_set.m_Syw		= m_sbxgdlg.m_fw;
				m_set.m_Fsp		= m_sbxgdlg.m_fp;
				m_set.m_Jsp		= m_sbxgdlg.m_jp;
				m_set.m_Shb		= m_sbxgdlg.m_sxh;
				m_set.m_Gl		= m_sbxgdlg.m_gl;
				m_set.m_Jsm		= m_sbxgdlg.m_jsm;
				m_set.m_Fj.Format("%s",dtstr);
				m_set.m_Yj.Format("%s",dtstry);
				//如果可以更新,则更新到数据库
				if(m_set.CanUpdate())
				{
					m_set.Update();
				}

				//更新完毕,关闭数据库
				if(m_set.IsOpen())
					m_set.Close();
				AfxMessageBox("修改成功!");
			}	
			else
			{
				
				if(m_set.IsOpen())
					m_set.Close();
				AfxMessageBox("该记录不存在,无法修改!");
				return;
			}	
		
		}
	
		catch(CDBException *e)
		{
			e->ReportError();
			return;
		}
	}
	RefreshData();


}

void CHandlg::OnChaxu() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	m_stw.TrimRight("");
	
	if(m_stw.GetLength()<=0)
	{
		AfxMessageBox("请输入设台单位进行查询");
		return;
	}


/*	if(!m_database.IsOpen())
	{
		m_database.Open(_T("InPone"));
	}
	*/
	m_listhand.DeleteAllItems();
	CHandSet2 m_handset(&m_database);
	CString strSQL;
	strSQL.Format("select * from HandMa where Sdw like '"+m_stw+"'");
	//strSQL.Format("select * from BusMa" );//where Place like '"+m_stw+"'");
	m_handset.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL);
	CDBVariant varValue;
	if(m_handset.GetRecordCount()!=0)
		m_handset.MoveFirst();
	char buf[20];
	int i=0;
	while(!m_handset.IsEOF())
	{
		int temp=0;
		
		//对整型数的显示处理
		m_handset.GetFieldValue(temp,varValue);
		sprintf(buf,"%d",varValue.m_iVal);
		m_listhand.InsertItem(i,buf);
		
		/*m_busset.GetFieldValue(1,varValue);
		m_listBus.InsertItem(i,varValue.m_pstring->GetBuffer(1));
		*/
		//对字符串的显示处理
		m_handset.GetFieldValue(1,varValue);
		m_listhand.SetItemText(i,1,varValue.m_pstring->GetBuffer(1));
		
		m_handset.GetFieldValue(2,varValue);
		m_listhand.SetItemText(i,2,varValue.m_pstring->GetBuffer(1));
		
		m_handset.GetFieldValue(3,varValue);
		m_listhand.SetItemText(i,3,varValue.m_pstring->GetBuffer(1));
		
		m_handset.GetFieldValue(4,varValue);
		m_listhand.SetItemText(i,4,varValue.m_pstring->GetBuffer(1));
		
		m_handset.GetFieldValue(5,varValue);
		m_listhand.SetItemText(i,5,varValue.m_pstring->GetBuffer(1));
	
		m_handset.GetFieldValue(6,varValue);
		m_listhand.SetItemText(i,6,varValue.m_pstring->GetBuffer(1));
		
		m_handset.GetFieldValue(7,varValue);
		m_listhand.SetItemText(i,7,varValue.m_pstring->GetBuffer(1));
	
		m_handset.GetFieldValue(8,varValue);
		m_listhand.SetItemText(i,8,varValue.m_pstring->GetBuffer(1));
				
		m_handset.GetFieldValue(9,varValue);
		m_listhand.SetItemText(i,9,varValue.m_pstring->GetBuffer(1));
		m_handset.GetFieldValue(10,varValue);
		m_listhand.SetItemText(i,10,varValue.m_pstring->GetBuffer(1));
	//	m_devghset.GetFieldValue(7,varValue);
	//	m_listgh.SetItemText(i,7,varValue.m_pstring->GetBuffer(1));
		
		m_handset.MoveNext();
		
		i++;
	}
}

void CHandlg::Printer()
{
	CHandSet2 m_set(&m_database);
	if(!m_database.IsOpen())
	{
		m_database.Open(_T("InPone"));
	}
   
	//进行打印了;
	char szprinter[80];
	char *szDevice,*szDriver,*szOutput;
	HDC hdcprint; 
	int x1,x2,x3;
	int y1,y2,y3,y4,y5,y6;

	char FileName[128];
	memset(FileName,0x00,sizeof(FileName));
	SetFilePath("\\Printer.ini",FileName);
	//定义一个打印作业
	DOCINFO di={sizeof(DOCINFO),"printer",NULL}; 
	// 得到设备字符串存入数组szprinter中
	GetProfileString("windows","device",",,,",szprinter,80); 

	x1 = GetPrivateProfileInt("Print","x1",0,FileName);
	x2 = GetPrivateProfileInt("Print","x2",0,FileName);
	x3 = GetPrivateProfileInt("Print","x3",0,FileName);

	y1 = GetPrivateProfileInt("Print","y1",0,FileName);
	y2 = GetPrivateProfileInt("Print","y2",0,FileName);
	y3 = GetPrivateProfileInt("Print","y3",0,FileName);
	y4 = GetPrivateProfileInt("Print","y4",0,FileName);
	y5 = GetPrivateProfileInt("Print","y5",0,FileName);
	y6 = GetPrivateProfileInt("Print","y6",0,FileName);

	// 将设备字符串分解
	if(NULL!=(szDevice=strtok(szprinter,","))&&
	NULL!=(szDriver=strtok(NULL,","))&&
	NULL!=(szOutput=strtok(NULL,",")))

	// 创建一个打印机设备句柄 
	if((hdcprint=CreateDC(szDriver,szDevice,szOutput,NULL))!=0)
	{
		
		if(StartDoc(hdcprint,&di)>0) //开始执行一个打印作业
		{ 
			StartPage(hdcprint); //打印机走纸,开始打印
			SaveDC(hdcprint); //保存打印机设备句柄
			// 输出一行文字
		//	TextOut(hdcprint,x1,y1,"这是一个例子",12); 
			// 输出一条直线
			
			CString		strSQL; 
			CDBVariant	varValue;
			char		buf[20];
			int			i=0;
			int			temp=0;

			strSQL.Format("select top 1 * from Handma order by ID desc");            
			m_set.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL);
		
			//对整型数的显示处理
			m_set.GetFieldValue(temp,varValue);
			sprintf(buf,"%06d",varValue.m_iVal);
			//第一行序号
			TextOut(hdcprint,x1,y1,buf,strlen(buf));
			//第二行单位
			m_set.GetFieldValue(1,varValue);
		
			TextOut(hdcprint,x2,y2,varValue.m_pstring->GetBuffer(1),strlen(varValue.m_pstring->GetBuffer(1)));

			//第三行使用范围
			m_set.GetFieldValue(2,varValue);
			TextOut(hdcprint,x2,y3,varValue.m_pstring->GetBuffer(1),strlen(varValue.m_pstring->GetBuffer(1)));
			//第四行第1列发射频率
			m_set.GetFieldValue(3,varValue);
			TextOut(hdcprint,x2,y4,varValue.m_pstring->GetBuffer(1),strlen(varValue.m_pstring->GetBuffer(1)));
			//第四第二列使用频率
			m_set.GetFieldValue(4,varValue);
			TextOut(hdcprint,x3,y4,varValue.m_pstring->GetBuffer(1),strlen(varValue.m_pstring->GetBuffer(1)));
			//第5行第1列设备型号
			m_set.GetFieldValue(5,varValue);
			TextOut(hdcprint,x2,y5,varValue.m_pstring->GetBuffer(1),strlen(varValue.m_pstring->GetBuffer(1)));
			//第5行第2列机身码
			m_set.GetFieldValue(6,varValue);
			TextOut(hdcprint,x3,y5,varValue.m_pstring->GetBuffer(1),strlen(varValue.m_pstring->GetBuffer(1)));
			//第6行第1列时间
			m_set.GetFieldValue(7,varValue);
			TextOut(hdcprint,x2,y6,varValue.m_pstring->GetBuffer(1),strlen(varValue.m_pstring->GetBuffer(1)));
			//第6行第2列时间
			m_set.GetFieldValue(8,varValue);
			TextOut(hdcprint,x3,y6,varValue.m_pstring->GetBuffer(1),strlen(varValue.m_pstring->GetBuffer(1)));

			RestoreDC(hdcprint,-1); //恢复打印机设备句柄	
			EndPage(hdcprint); //打印机停纸,停止打印
			EndDoc(hdcprint); //结束一个打印作业
			MessageBox("打印完毕!","提示",MB_ICONINFORMATION);
		}
		// 用API函数DeleteDC销毁一个打印机设备句柄 
		DeleteDC(hdcprint);
		
	}
	else
	{
		MessageBox("没有默认打印机,或者没有安装打印机!");
		return;
	

	}

}

void CHandlg::OnShachu() 
{
	// TODO: Add your control notification handler code here
	int		i=m_listhand.GetSelectionMark();
	CString strSQL;
	CString temp;


	if (i==-1)
	{
		MessageBox("请选择一条记录!");
	}

	else
	{
	
		if(MessageBox("请确定是否要删除","标题",MB_OKCANCEL)==IDCANCEL)
			return;
		int keyid=atoi(m_listhand.GetItemText(i,0));	
		strSQL.Format("delete from HandMa where ID=%d",keyid);
		//strSQL.Format("delete from BusMa where num=%s",m_listBus.GetItemText(i,0));
		m_database.ExecuteSQL(strSQL);
		m_database.Close();
		RefreshData();
	}
}


void CHandlg::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	memset(AddHand,0x00,sizeof(AddHand));
	int i   = m_listhand.GetSelectionMark();
	m_no	= m_listhand.GetItemText(i,1);
	m_stw	= m_listhand.GetItemText(i,2);

	m_sw	= m_listhand.GetItemText(i,3);
	m_fp	= m_listhand.GetItemText(i,4);
	m_jp	= m_listhand.GetItemText(i,5);
	m_gl	= m_listhand.GetItemText(i,6);
	m_sbh	= m_listhand.GetItemText(i,7);
	m_jsm	= m_listhand.GetItemText(i,8);
	m_fj	= m_listhand.GetItemText(i,9);
	m_yj	= m_listhand.GetItemText(i,10);
	for(int j =2;j<=8;j++)
	{	
		strcat(AddHand,m_listhand.GetItemText(i,j));
		strcat(AddHand,"|");

	}
    UpdateData(FALSE);
	*pResult = 0;
}

⌨️ 快捷键说明

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