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

📄 printdbview.cpp

📁 在游戏设计的时候
💻 CPP
📖 第 1 页 / 共 3 页
字号:
					var = m_pRecordset->GetCollect("磨抛投型");
					if(var.vt != VT_NULL)
						mp = (LPCSTR)_bstr_t(var);
					else
						mp="0";
					var = m_pRecordset->GetCollect("封接投锥");
					if(var.vt != VT_NULL)
						fzhui = (LPCSTR)_bstr_t(var);
					else
						fzhui="0";
					var = m_pRecordset->GetCollect("封接投屏");
					if(var.vt != VT_NULL)
						fping = (LPCSTR)_bstr_t(var);
					else
						fping="0";
					
					if ((i>=1)&&(i<=9))
					{
						iScreen1+=atoi(cping);
						iCone1+=atoi(czhui);

					}
					if ((i>=10)&&(i<=20))
					{
						iScreen2+=atoi(cping);
						iCone2+=atoi(czhui);

					}
					if ((i>=21)&&(i<=30))
					{
						iScreen3+=atoi(cping);
						iCone3+=atoi(czhui);

					}

					iScreenDayNum+=atoi(cping);
					iConeDayNum+=atoi(czhui);
					
					
				
					m_List.AddString(FilStrWithNul(date,11)+FilStrWithNul(section,12)+FilStrWithNul(cping,12)+FilStrWithNul(czhui,12)+FilStrWithNul(mp,12)+FilStrWithNul(fzhui,12)+FilStrWithNul(fping,12));
					m_pRecordset->Move(1);
				}
				CanUseTotal=TRUE;
				m_SumList.ResetContent();
				HaveSum=FALSE;
				PrintType=1;
				return;
			}
			/////////////////////////////////////////////////////////////////////////
			m_pRecordset->Move(30);
		}
		AfxMessageBox("数据库中不存在您检索的数据,您输入的日期可能早于数据库的最早记录,请您核对日期后重新查询!");
		
	}
	
	
	catch(_com_error *e)
	{
		AfxMessageBox(e->ErrorMessage());
	}
		
		
		
		
}

BOOL CPrintDBView::CStringCompare(CString str1, CString str2)//返回true为str1大,返回false为str2大
{
	int i,j;
	if (str1.GetAt(3)>str2.GetAt(3))
	{
		return TRUE;
	}
	else if (str1.GetAt(3)<str2.GetAt(3))
	{
		return FALSE;
	}
	else
	{
		for (i=5;str1.GetAt(i)!='/';i++)
		{
		}
		for (j=5;str2.GetAt(j)!='/';j++)
		{
		}
		if ((i==7)&&(j==7))
		{
			if (str1.GetAt(6)>str2.GetAt(6))
			{
				return TRUE;
			}else if (str1.GetAt(6)<str2.GetAt(6))
			{
				return FALSE;
			}else
			{
				if (str1.GetLength()>str2.GetLength())
				{
					return TRUE;
				}else if (str1.GetLength()<str2.GetLength())
				{
					return FALSE;
				}else
				{
					if (str1.GetLength()==10)
					{
						if (str1.GetAt(8)>str2.GetAt(8))
						{
							return TRUE;
						}else if (str1.GetAt(8)<str2.GetAt(8))
						{
							return FALSE;
						}else
						{
							if (str1.GetAt(9)>str2.GetAt(9))
							{
								return TRUE;
							}else if (str1.GetAt(9)<str2.GetAt(9))
							{
								return FALSE;
							}
						}
					}else
					{
						if (str1.GetAt(8)>str2.GetAt(8))
						{
							return TRUE;
						}else if (str1.GetAt(8)<str2.GetAt(8))
						{
							return FALSE;
						}
					}
				}
			}
		}else if ((i==6)&&(j==6))
		{
			if (str1.GetAt(5)>str2.GetAt(5))
			{
				return TRUE;
			}
			else if (str1.GetAt(5)<str2.GetAt(5))
			{
				return FALSE;
			}
			else
			{
				if (str1.GetLength()>str2.GetLength())
				{
					return TRUE;
				}else  if (str1.GetLength()<str2.GetLength())
				{
					return FALSE;
				}else
				{
					if (str1.GetLength()==9)
					{
						if (str1.GetAt(7)>str2.GetAt(7))
						{
							return TRUE;
						}else if (str1.GetAt(7)<str2.GetAt(7))
						{
							return FALSE;
						}
						else
						{
							if (str1.GetAt(8)>str2.GetAt(8))
							{
								return TRUE;
							}else if (str1.GetAt(8)<str2.GetAt(8))
							{
								return FALSE;
							}
						}
					}else
					{
						if (str1.GetAt(7)>str2.GetAt(7))
						{
							return TRUE;
						}
						else if (str1.GetAt(7)<str2.GetAt(7))
						{
							return FALSE;
						}
					}
				}
			}
		}
		else if (i<j)
		{
			return FALSE;
		}else
		{
			return TRUE;
		}
	}
return FALSE;
}

int CPrintDBView::ReturnTimeSection(int time)
{
		if(time<15)//0:15
		return 21;
	else if(time<75)//1:15
		return 22;
	else if(time<135)//2:15
		return 23;
	else if(time<225)//3:45
		return 24;
	else if(time<285)//4:45
		return 25;
	else if(time<345)//5:45
		return 26;
	else if(time<380)//6:20
		return 27;
	else if(time<390)//6:30
		return 28;
	else if(time<405)//6:45
		return 29;
	else if(time<465)//7:45
		return 0;
	else if(time<495)//8:15
		return 1;
	else if(time<555)//9:15
		return 2;
	else if(time<615)//10:15
		return 3;
	else if(time<705)//11:45
		return 4;
	else if(time<765)//12:45
		return 5;
	else if(time<800)//13:20
		return 6;
	else if(time<810)//13:30
		return 7;
	else if(time<825)//13:45
		return 8;
	else if(time<885)//14:45
		return 9;
	else if(time<930)//15:30
		return 10;
	else if(time<990)//16:30
		return 11;
	else if(time<1050)//17:30
		return 12;
	else if(time<1125)//18:45
		return 13;
	else if(time<1185)//19:45
		return 14;
	else if(time<1245)//20:45
		return 15;
	else if(time<1280)//21:20
		return 16;
	else if(time<1290)//21:30
		return 17;
	else if(time<1305)//21:45
		return 18;
	else if(time<1365)//22:45
		return 19;
	else if(time<1395)//23:15
		return 20;
	else 
		return 21;

}

CString CPrintDBView::FilStrWithNul(CString &str, int i)
{
	CString sNull="";
	int j=str.GetLength();
	if (j<i)
	{
		for (int k=0;k<(i-j);k++)
		{
			sNull+=" ";
		}
	}
	str=str+sNull;
	return str;

}

BOOL CPrintDBView::IsLinkTab()
{
	//////////////////////////////////////////
	// 使用ADO创建数据库记录集
	m_pRecordset.CreateInstance(__uuidof(Recordset));
	// 在ADO操作中建议语句中要常用try...catch()来捕获错误信息,
	// 因为它有时会经常出现一些想不到的错误。jingzhou xu
	try
	{
		m_pRecordset->Open("SELECT * FROM 玻壳产品记录",                // 查询DemoTable表中所有字段
			theApp.m_pConnection.GetInterfacePtr(),	 // 获取库接库的IDispatch指针
			adOpenDynamic,
			adLockOptimistic,
			adCmdText);
	}
	catch(_com_error *e)
	{
		AfxMessageBox(e->ErrorMessage());
		return FALSE;
	}
	IsLinkTable=TRUE;
	AfxMessageBox("导入数据库成功");
	return TRUE;

/////////////////////////////////////

}



BOOL CPrintDBView::DestroyWindow() 
{
	// TODO: Add your specialized code here and/or call the base class
	if (IsLinkTable)
	{
		m_pRecordset->Close();
		m_pRecordset=NULL;
	}
	
	return CFormView::DestroyWindow();
}

void CPrintDBView::OnTotalnum() 
{
	if (CanUseTotal)
	{
	m_SumList.ResetContent();
	// TODO: Add your control notification handler code here
	CString s1,s2,s3,sday,sNull,sZero;
	s1="早班产量";s2="中班产量";s3="晚班产量";
	sday="  总产量";sNull="";sZero="0";
	CString sScreen1,sScreen2,sScreen3,sScreenDayNum;
	CString sCone1,sCone2,sCone3,sConeDayNum;
	sScreen1.Format("%d",iScreen1);
	sScreen2.Format("%d",iScreen2);
	sScreen3.Format("%d",iScreen3);
	sCone1.Format("%d",iCone1);
	sCone2.Format("%d",iCone2);
	sCone3.Format("%d",iCone3);
	sScreenDayNum.Format("%d",iScreenDayNum);
	sConeDayNum.Format("%d",iConeDayNum);
	m_SumList.AddString(FilStrWithNul(s1,11)+FilStrWithNul(sNull,12)+FilStrWithNul(sScreen1,12)+FilStrWithNul(sCone1,12)+FilStrWithNul(sZero,12)+FilStrWithNul(sZero,12)+FilStrWithNul(sZero,12));
	m_SumList.AddString(FilStrWithNul(s2,11)+FilStrWithNul(sNull,12)+FilStrWithNul(sScreen2,12)+FilStrWithNul(sCone2,12)+FilStrWithNul(sZero,12)+FilStrWithNul(sZero,12)+FilStrWithNul(sZero,12));
	m_SumList.AddString(FilStrWithNul(s3,11)+FilStrWithNul(sNull,12)+FilStrWithNul(sScreen3,12)+FilStrWithNul(sCone3,12)+FilStrWithNul(sZero,12)+FilStrWithNul(sZero,12)+FilStrWithNul(sZero,12));
	m_SumList.AddString(FilStrWithNul(sday,11)+FilStrWithNul(sNull,12)+FilStrWithNul(sScreenDayNum,12)+FilStrWithNul(sConeDayNum,12)+FilStrWithNul(sZero,12)+FilStrWithNul(sZero,12)+FilStrWithNul(sZero,12));
	HaveSum=TRUE;
	}
	
}

void CPrintDBView::OnUpdateStandardPrint(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->Enable(IsLinkTable);
	
}

void CPrintDBView::OnDraw(CDC* pDC) 
{
	// TODO: Add your specialized code here and/or call the base class

}

void CPrintDBView::OnPrintDB() 
{
	// TODO: Add your control notification handler code here
	
	if (CanUseTotal==TRUE)
	{
		CPrintDialog dlg(FALSE,
			
			PD_NOPAGENUMS|PD_NOSELECTION,
			
			this);
		
		if(dlg.DoModal() == IDOK)
			
		{
			
			CDC dc;
			
			dc.Attach(dlg.GetPrinterDC());//把打印设备环境附加到DC对象
			
			
			DOCINFO di; 
			
			di.cbSize = sizeof(DOCINFO);
			
			di.lpszDocName = "SimplePrintDoc";
			
			di.lpszOutput = NULL;
			
			di.lpszDatatype = NULL;
			
			di.fwType = 0;
			
			dc.StartDoc(&di); //通知打印机驱动程序执行一新的打印任务
			
			dc.StartPage();//通知打印机驱动程序打印新页
			
			dc.SetMapMode(MM_TEXT);//设置当前影射模式
			
			
			
			CString sTitle="玻 壳 数 据 库 查 询 系 统";
			CString sCompany="津京玻壳股份有限公司";
			CString sDate="打印时间:";
			CFont titleFont,dataFont;
			int iCharWidth,iCharHeight;
			TEXTMETRIC tm;
			CTime cutTime=CTime::GetCurrentTime();
			CString sdate;
			CString string="";
			CString sComment="注:表中'时间段'内的时间为该时间段结束时间,该时间段的起始时间实为上一时间段内的时间!";
			
			
			
			
			sdate.Format("%d/%d/%d-%d:%d:%d",cutTime.GetYear(),cutTime.GetMonth(),cutTime.GetDay(),cutTime.GetHour(),cutTime.GetMinute(),cutTime.GetSecond());
			sDate+=sdate;
			dataFont.CreateFont(80,0,0,0,400,FALSE,FALSE,0,ANSI_CHARSET,
				OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
				DEFAULT_PITCH|FF_MODERN,"宋体");
			titleFont.CreateFont(120,0,0,0,900,FALSE,FALSE,0,ANSI_CHARSET,
				OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
				DEFAULT_PITCH|FF_MODERN,"宋体");
			dc.SelectObject(&dataFont);
			dc.GetTextMetrics(&tm);
			iCharWidth=tm.tmAveCharWidth;
			iCharHeight=tm.tmHeight;
			dc.SelectObject(&titleFont);
			dc.TextOut(38*iCharWidth,4*iCharHeight,sTitle);
			dc.SelectObject(&dataFont);
			dc.TextOut(15*iCharWidth,7*iCharHeight,sCompany);
			dc.TextOut(72*iCharWidth,7*iCharHeight,sDate);
			
			
			//表格中的数据
			for (int i=0;i<31;i++)
			{
				m_List.GetText(i,string);
				dc.TextOut((15+2)*iCharWidth,(int)((10+2*i+0.5)*iCharHeight),string);
			}
			//统计表格中的数据
			if (HaveSum==TRUE)
			{
				
				for (i=0;i<4;i++)
				{
					m_SumList.GetText(i,string);
					dc.TextOut((15+2)*iCharWidth,(int)((62+10+2*i+0.5)*iCharHeight),string);
				}
			}
			dc.TextOut(15*iCharWidth,(int)(80.5*iCharHeight),sComment);
			//画表格的竖线
			for ( i=0;i<8;i++)
			{
				dc.MoveTo(15*iCharWidth+i*12*iCharWidth,10*iCharHeight);
				dc.LineTo(15*iCharWidth+i*12*iCharWidth,80*iCharHeight);
			}
			//画表格的横线
			for (i=0;i<36;i++)
			{
				dc.MoveTo(15*iCharWidth,(10+2*i)*iCharHeight);
				dc.LineTo((15+84)*iCharWidth,(10+2*i)*iCharHeight);
			}
			
			
			//一下代码,仅仅是表格的装饰效果
			
			CPen pen(PS_SOLID,7,RGB(0,0,0));
			dc.SelectObject(&pen);
			//描黑竖边框
			dc.MoveTo(15*iCharWidth,10*iCharHeight);
			dc.LineTo(15*iCharWidth,80*iCharHeight);
			dc.MoveTo(15*iCharWidth+7*12*iCharWidth,10*iCharHeight);
			dc.LineTo(15*iCharWidth+7*12*iCharWidth,80*iCharHeight);
			//描黑横边框
			dc.MoveTo(15*iCharWidth,(10)*iCharHeight);
			dc.LineTo((15+84)*iCharWidth,(10)*iCharHeight);
			dc.MoveTo(15*iCharWidth,(10+70)*iCharHeight);
			dc.LineTo((15+84)*iCharWidth,(10+70)*iCharHeight);

⌨️ 快捷键说明

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