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

📄 lessondoc.cpp

📁 为学校教导用的排课系统。
💻 CPP
📖 第 1 页 / 共 4 页
字号:
		}
		break;
	case 1:
		if(1)
		{
			pDC->TextOut(Form.left+Form.Width()/2-lf.lfWidth*4,-1*(Form.top-lf.lfHeight*3/2),"日 课 表");
			lf.lfHeight=OneV/3;
			lf.lfWidth=OneH/5;
			strcpy(lf.lfFaceName,pa->m_Print.m_Font);
			f.CreateFontIndirect(&lf);
			pDC->SelectObject(&f);
			pDC->TextOut(Form.right-Form.Width()/4,-1*(Form.top-lf.lfHeight*4/3),NowTime);
			pDC->TextOut(Form.left+OneH/4-lf.lfWidth,-1*(Form.top+OneV-lf.lfHeight*2),"午");
			pDC->TextOut(Form.left+OneH/4-lf.lfWidth,-1*(Form.top+OneV+lf.lfHeight),"别");
			pDC->TextOut(Form.left+OneH*3/4-lf.lfWidth,-1*(Form.top+OneV-lf.lfHeight*2),"节");
			pDC->TextOut(Form.left+OneH*3/4-lf.lfWidth,-1*(Form.top+OneV+lf.lfHeight),"次");
			CString Class;Class.Format("%s",GetGradeClassName(pInfo->m_nCurPage,1));
			pDC->TextOut(Form.left,-1*(Form.bottom+lf.lfHeight/2),Class);
			pDC->TextOut(Form.left+OneH*10/9,-1*(Form.top+lf.lfHeight*2),"时");
			pDC->TextOut(Form.left+OneH*5/3,-1*(Form.top+lf.lfHeight*4),"间");
			pDC->TextOut(Form.left+OneH*2,-1*(Form.top+lf.lfHeight*3/2),"星");
			pDC->TextOut(Form.left+OneH*5/2,-1*(Form.top+lf.lfHeight*3),"期");
			pDC->TextOut(Form.left+OneH/4-lf.lfWidth,-1*(Form.top+OneV*3),"上");
			pDC->TextOut(Form.left+OneH/4-lf.lfWidth,-1*(Form.top+OneV*5),"午");
			pDC->TextOut(Form.left+OneH/4-lf.lfWidth,-1*(Form.top+OneV*8),"下");
			pDC->TextOut(Form.left+OneH/4-lf.lfWidth,-1*(Form.top+OneV*9),"午");
			pDC->TextOut(Form.left+OneH/4-lf.lfWidth*2/3,-1*(Form.bottom-OneV+lf.lfHeight),"晚间");
			pDC->TextOut(Form.left+OneH*3/4-lf.lfWidth,-1*(Form.top+OneV*5/2-lf.lfHeight),"早");
			pDC->TextOut(Form.left+OneH*3/4-lf.lfWidth,-1*(Form.top+OneV*5/2),"读");
			CString StanzaStr;
			for(int i=1;i<=pDoc->m_Info.m_Stanza-1;i++)
			{
				StanzaStr.Format("%d",i);
				pDC->TextOut(Form.left+OneH*3/4-lf.lfWidth/2,-1*(Form.top+OneV*i+OneV*5/2-lf.lfHeight/2),StanzaStr);
			}
			lf.lfWidth=OneH/6;
			f.CreateFontIndirect(&lf);
			pDC->SelectObject(&f);
			for(i=0;i<=pDoc->m_Info.m_Stanza;i++)
			{
				if(i>TimeStr.GetSize()-1)break;
				pDC->TextOut(Form.left+OneH*5/4-lf.lfWidth*2/3,-1*(Form.top+OneV*i+OneV*5/2-lf.lfHeight/2),TimeStr.GetAt(i));
			}
			lf.lfWidth=OneH/3;
			lf.lfHeight=OneV;
			lf.lfWeight=300;
			f.CreateFontIndirect(&lf);
			pDC->SelectObject(&f);
			for(i=0;i<pDoc->m_Info.m_Week;i++)
				pDC->TextOut(Star.x+OneH*i+OneH/2-lf.lfWidth,-1*(Form.top+OneV-lf.lfHeight/2),GetNumStr(i+1));
			//还原字体
			pDC->SelectObject(poldf);
		}
		break;
	case 2:
		if(1)
		{
			lf.lfWidth=Form.Width()/30;
			f.CreateFontIndirect(&lf);
			pDC->SelectObject(&f);
			pDC->TextOut(Form.left+Form.Width()/2-lf.lfWidth*4,-1*(Form.top-lf.lfHeight*3/2),"日 课 表");
			lf.lfHeight=OneV*2/3;
			lf.lfWidth=OneH/3;
			strcpy(lf.lfFaceName,pa->m_Print.m_Font);
			f.CreateFontIndirect(&lf);
			pDC->SelectObject(&f);
			pDC->TextOut(Form.right-Form.Width()/6,-1*(Form.top-lf.lfHeight*4/3),NowTime);
			pDC->TextOut(Form.left+OneH/2-lf.lfWidth,-1*(Form.top+OneV-lf.lfHeight),"午");
			pDC->TextOut(Form.left+OneH/2-lf.lfWidth,-1*(Form.top+OneV*2),"别");
			pDC->TextOut(Form.left+OneH/2-lf.lfWidth,-1*(Form.top+OneV*4),"上");
			pDC->TextOut(Form.left+OneH/2-lf.lfWidth,-1*(Form.top+OneV*6),"午");
			pDC->TextOut(Form.left+OneH/2-lf.lfWidth,-1*(Form.top+OneV*9),"下");
			pDC->TextOut(Form.left+OneH/2-lf.lfWidth,-1*(Form.top+OneV*10),"午");
			pDC->TextOut(Form.left+OneH-lf.lfWidth*2,-1*(Form.bottom-OneV+lf.lfHeight/4),"晚间");
			CString Grade;Grade.Format("%s",GetGradeClassName(pInfo->m_nCurPage,0));
			pDC->TextOut(Form.left,-1*(Form.bottom+lf.lfHeight/2),Grade);
			CString StanzaStr;
			for(int i=1;i<=pDoc->m_Info.m_Stanza-1;i++)
			{
				StanzaStr.Format("%d",i);
				pDC->TextOut(Form.left+OneH*3/2-lf.lfWidth/2,-1*(Form.top+OneV*i+OneV*7/2-lf.lfHeight/2),StanzaStr);
			}
			pDC->TextOut(Form.left+OneH*3/2-lf.lfWidth*4/5,-1*(Form.top+OneV*4-lf.lfHeight*5/4),"早");
			int cnum=pDoc->GetClassCount(pInfo->m_nCurPage);
			for(i=0;i<pDoc->m_Info.m_Week;i++)
				pDC->TextOut(Star.x+OneH*cnum*i+OneH*cnum/2-lf.lfWidth,-1*(Form.top+OneV/2-lf.lfHeight/2),GetNumStr(i+1));
			CString Class;
			for(i=0;i<pDoc->m_Info.m_Week;i++)
				for(int j=0;j<cnum;j++)
				{
					Class.Format("%d",j+1);
					pDC->TextOut(Star.x+OneH*(j+i*cnum)+OneH/2-lf.lfWidth,-1*(Form.top+OneV*2-lf.lfHeight),Class);
				}
			lf.lfHeight=OneV/2;lf.lfWidth=OneH/5;
			f.CreateFontIndirect(&lf);
			pDC->SelectObject(&f);
			pDC->TextOut(Form.left+OneH*11/10,-1*(Form.top+OneV/3),"星期");
			pDC->TextOut(Form.left+OneH*4/3,-1*(Form.top+OneV*11/10),"班");
			pDC->TextOut(Form.left+OneH*8/5,-1*(Form.top+OneV*8/5),"级");
			pDC->TextOut(Form.left+OneH*11/10,-1*(Form.top+OneV*2),"节");
			pDC->TextOut(Form.left+OneH*4/3,-1*(Form.top+OneV*5/2),"次");
		
		
			//还原字体
			pDC->SelectObject(poldf);
		}
		break;
	case 3:
		if(1)
		{
			lf.lfWidth=Form.Width()/30;
			f.CreateFontIndirect(&lf);
			pDC->SelectObject(&f);
			pDC->TextOut(Form.left+Form.Width()/2-lf.lfWidth*4,-1*(Form.top-lf.lfHeight*3/2),"日 课 表");
			lf.lfHeight=OneV*2/3;
			lf.lfWidth=OneH/3;
			strcpy(lf.lfFaceName,pa->m_Print.m_Font);
			f.CreateFontIndirect(&lf);
			pDC->SelectObject(&f);
			pDC->TextOut(Form.right-Form.Width()/6,-1*(Form.top-lf.lfHeight*4/3),NowTime);
			pDC->TextOut(Form.left+OneH/2-lf.lfWidth,-1*(Form.top+OneV-lf.lfHeight),"午");
			pDC->TextOut(Form.left+OneH/2-lf.lfWidth,-1*(Form.top+OneV*2),"别");
			pDC->TextOut(Form.left+OneH/2-lf.lfWidth,-1*(Form.top+OneV*4),"上");
			pDC->TextOut(Form.left+OneH/2-lf.lfWidth,-1*(Form.top+OneV*6),"午");
			pDC->TextOut(Form.left+OneH/2-lf.lfWidth,-1*(Form.top+OneV*9),"下");
			pDC->TextOut(Form.left+OneH/2-lf.lfWidth,-1*(Form.top+OneV*10),"午");
			pDC->TextOut(Form.left+OneH-lf.lfWidth*2,-1*(Form.bottom-OneV+lf.lfHeight/4),"晚间");
			CString StanzaStr;
			for(int i=1;i<=pDoc->m_Info.m_Stanza-1;i++)
			{
				StanzaStr.Format("%d",i);
				pDC->TextOut(Form.left+OneH*3/2-lf.lfWidth/2,-1*(Form.top+OneV*i+OneV*7/2-lf.lfHeight/2),StanzaStr);
			}
			pDC->TextOut(Form.left+OneH*3/2-lf.lfWidth*4/5,-1*(Form.top+OneV*4-lf.lfHeight*5/4),"早");
			int cnum=0;
			for(i=0;i<pDoc->GetGradeCount();i++)
				cnum+=pDoc->GetClassCount(i+1);
			for(i=0;i<pDoc->m_Info.m_Week;i++)
				pDC->TextOut(Star.x+OneH*cnum*i+OneH*cnum/2-lf.lfWidth,-1*(Form.top+OneV/2-lf.lfHeight/2),GetNumStr(i+1));
			CString Class,Grade;int n=0;
			for(i=0;i<pDoc->m_Info.m_Week;i++)
				for(int g=0;g<pDoc->GetGradeCount();g++)
				{
					Grade=GetNumStr(g+1);
					for(int c=0;c<pDoc->GetClassCount(g+1);c++)
					{
						pDC->TextOut(Star.x+OneH*n+OneH/2-lf.lfWidth,-1*(Form.top+OneV*2-lf.lfHeight),Grade);
						Class.Format("%d",c+1);
						pDC->TextOut(Star.x+OneH*n+OneH/2-lf.lfWidth,-1*(Form.top+OneV*2),Class);
						n++;
					}
				}
			lf.lfHeight=OneV/2;lf.lfWidth=OneH/5;
			f.CreateFontIndirect(&lf);
			pDC->SelectObject(&f);
			pDC->TextOut(Form.left+OneH*11/10,-1*(Form.top+OneV/3),"星期");
			pDC->TextOut(Form.left+OneH*4/3,-1*(Form.top+OneV*11/10),"班");
			pDC->TextOut(Form.left+OneH*8/5,-1*(Form.top+OneV*8/5),"级");
			pDC->TextOut(Form.left+OneH*11/10,-1*(Form.top+OneV*2),"节");
			pDC->TextOut(Form.left+OneH*4/3,-1*(Form.top+OneV*5/2),"次");
		
		
			//还原字体
			pDC->SelectObject(poldf);
		}
		break;
	default:
		;
	}
}

void CLessonDoc::PRINT::MakeSubject(CDC *	pDC,CPrintInfo * pInfo,int style)
{
	CLessonApp * pa=(CLessonApp *)AfxGetApp();
	LOGFONT lf;
	lf.lfStrikeOut=0;
	lf.lfUnderline=0;
	lf.lfItalic=0;
	lf.lfEscapement=0;
	lf.lfCharSet=134;
	strcpy(lf.lfFaceName,pa->m_Print.m_Font);
	lf.lfHeight=OneV/2;
	lf.lfWidth=OneH/5;
	CFont f;
	f.CreateFontIndirect(&lf);
	CFont * poldF=pDC->SelectObject(&f);
	switch(style)
	{
	case 0:
		if(1)
		{
			lf.lfHeight=OneV*2/5;
			lf.lfWidth=OneH/5;
			f.CreateFontIndirect(&lf);
			pDC->SelectObject(&f);
			CString subject,gc;
			CTeacher * Teacher=pDoc->GetTeacher(pInfo->m_nCurPage-1);
			CMission * Mission;
			for(int i=Teacher->m_MissionArray.GetSize()-1;i>=0;i--)
			{
				Mission=(CMission *)Teacher->m_MissionArray.GetAt(i);
				for(int s=0;s<pDoc->m_Info.m_Stanza;s++)
					for(int w=0;w<pDoc->m_Info.m_Week;w++)
					{
						if(Mission->m_Sit[w][s])
						{
							subject=Mission->m_Subject;
							gc.Format("%s(%d)",GetNumStr(Mission->m_Grade),Mission->m_Class);
							pDC->TextOut(Star.x+w*OneH+OneH/2-lf.lfWidth*2,-1*(Star.y+s*OneV+OneV/2-lf.lfHeight),subject);
							lf.lfWidth=OneH/6;
							CFont nf;nf.CreateFontIndirect(&lf);
							pDC->SelectObject(&nf);
							pDC->TextOut(Star.x+w*OneH+OneH/2-lf.lfWidth*17/8,-1*(Star.y+s*OneV+OneV/2),gc);
							pDC->SelectObject(&f);
						}
					}
			}
		}
		break;
	case 1:
		if(1)
		{
			CString subject;CMission * M;
			for(int s=0;s<pDoc->m_Info.m_Stanza;s++)
			{
				for(int w=0;w<pDoc->m_Info.m_Week;w++)
				{
					M=pDoc->GetMission(GetGradeClassIndex(pInfo->m_nCurPage,0),GetGradeClassIndex(pInfo->m_nCurPage,1),w+1,s+1);
					if(M)
						subject=M->m_Subject;
					else
						subject="自习";
					pDC->TextOut(Star.x+w*OneH+OneH/2-lf.lfWidth*7/4,-1*(Star.y+OneV*s+OneV/2-lf.lfHeight/2),subject);
				}
			}
		}
		break;
	case 2:
		if(1)
		{
			CString subject;CMission * M;int cnum=pDoc->GetClassCount(pInfo->m_nCurPage);
			for(int s=0;s<pDoc->m_Info.m_Stanza;s++)
			{
				for(int w=0;w<pDoc->m_Info.m_Week;w++)
					for(int c=0;c<cnum;c++)
					{
						M=pDoc->GetMission(pInfo->m_nCurPage,c+1,w+1,s+1);
						if(M)
							subject=M->m_Subject;
						else
							subject="自习";
						pDC->TextOut(Star.x+OneH*(c+w*cnum)+OneH/2-lf.lfWidth*7/4,-1*(Star.y+OneV*s+OneV/2-lf.lfHeight/2),subject);
					}
			}
		}
		break;
	case 3:
		if(1)
		{
			lf.lfHeight=OneV*2/5;
			lf.lfWidth=OneH/3;
			f.CreateFontIndirect(&lf);
			pDC->SelectObject(&f);
			CString subject;CMission * M;int n=0;
			for(int s=0;s<pDoc->m_Info.m_Stanza;s++)
			{
				n=0;
				for(int w=0;w<pDoc->m_Info.m_Week;w++)
				for(int g=0;g<pDoc->GetGradeCount();g++)
				for(int c=0;c<pDoc->GetClassCount(g+1);c++)
				{
					M=pDoc->GetMission(g+1,c+1,w+1,s+1);
					if(M)
						subject=M->m_Subject;
					else
						subject="自习";
					pDC->TextOut(Star.x+n*OneH+OneH/2-lf.lfWidth,-1*(Star.y+s*OneV+OneV/2-lf.lfHeight),subject.Left(2));
					subject.Delete(0,2);
					pDC->TextOut(Star.x+n*OneH+OneH/2-lf.lfWidth,-1*(Star.y+s*OneV+OneV/2),subject.Left(2));
					n++;
				}
			}
		}
		break;
	default:
		;
	}
	////////还原字体
	pDC->SelectObject(poldF);
}

int CLessonDoc::PRINT::SetStyle(CPrintInfo * pInfo)
{
	int style=-1;
	if(pDoc->m_Info.m_ViewStatus==TEACHER_MISSION)
	{
		style=-1;
	}
	else
	{
		if(pDoc->m_Info.m_ViewStatus==TEACHER_LESSON)
		{
			style=0;
			pInfo->SetMaxPage(pDoc->m_TeacherArray.GetSize());
		}
		else
		{
			if(pDoc->m_Info.m_SelectGrade<1)
			{
				style=3;
				pInfo->SetMaxPage(1);
			}
			else
			{
				if(pDoc->m_Info.m_SelectClass<1)
				{
					style=2;
					pInfo->SetMaxPage(pDoc->GetGradeCount());
				}
				else
				{
					style=1;
					int TPage=0;
					for(int i=0;i<pDoc->GetGradeCount();i++)
						TPage+=pDoc->GetClassCount(i+1);
					pInfo->SetMaxPage(TPage);
				}
			}
		}
	}
	return style;
}

CString CLessonDoc::PRINT::GetNumStr(int i)
{
	CString str;
	switch(i)
	{
	case 0:
		str="零";
		break;
	case 1:
		str="一";
		break;
	case 2:
		str="二";
		break;
	case 3:
		str="三";
		break;
	case 4:
		str="四";
		break;
	case 5:
		str="五";
		break;
	case 6:
		str="六";
		break;
	case 7:
		str="七";
		break;
	case 8:
		str="八";
		break;
	case 9:
		str="九";
		break;
	case 10:
		str="十";
		break;
	default:
		str="多";
	}
	return str;
}

CString CLessonDoc::PRINT::GetGradeClassName(int nIndex, int style)
{
	CString str;
	if(style)//根据nIndex找班级名称
	{
		int n=nIndex,g=0,c=0;
		for(int i=1;i<=pDoc->GetGradeCount();i++)
		{
			if(n<=pDoc->GetClassCount(i))
			{
				g=i;
				c=n;
				break;
			}
			else
				n=n-pDoc->GetClassCount(i);
		}
		str.Format("%s年级%d班",GetNumStr(g),n);
	}
	else//根据nIndex找年级名称
	{
		str.Format("%s年级",GetNumStr(nIndex));
	}
	return str;
}

int CLessonDoc::PRINT::GetGradeClassIndex(int nIndex, int style)
{
	int n=nIndex,g=0,c=0;
	for(int i=1;i<=pDoc->GetGradeCount();i++)
	{
		if(n<=pDoc->GetClassCount(i))
		{
			g=i;
			c=n;
			break;
		}
		else
			n=n-pDoc->GetClassCount(i);
	}
	if(style)//根据nIndex找班级
	{
		return c;
	}
	else//根据nIndex找年级
	{
		return g;
	}
}


void CLessonDoc::OnUpdateFilePrint(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	CLessonApp * pa=(CLessonApp *)AfxGetApp();
	if(pa->m_IsRegistry)
		pCmdUI->Enable();
	else
		pCmdUI->Enable(0);
}

⌨️ 快捷键说明

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