📄 subform1.cpp
字号:
// SubForm1.cpp : implementation file
//
#include "stdafx.h"
#include "学生成绩管理系统.h"
#include "学生成绩管理系统Doc.h"
#include "MainFrm.h"
#include "SubForm1.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSubForm1
IMPLEMENT_DYNCREATE(CSubForm1, CFormView)
CSubForm1::CSubForm1()
: CFormView(CSubForm1::IDD)
{
//{{AFX_DATA_INIT(CSubForm1)
m_searchname = _T("");
m_searchno = _T("");
//}}AFX_DATA_INIT
dayin1.LoadBitmap(IDB_DAYIN);
dayin2.LoadBitmap(IDB_DAYIN);
preview1.LoadBitmap(IDB_PREVIEW);
preview2.LoadBitmap(IDB_PREVIEW);
}
CSubForm1::~CSubForm1()
{
}
void CSubForm1::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSubForm1)
DDX_Control(pDX, IDC_COMBOYEAR, m_comboyear);
DDX_Control(pDX, IDC_COMBOZHUANYIE, m_combozhuanyie);
DDX_Control(pDX, IDC_COMBOCOURSE, m_combocourse);
DDX_Control(pDX, IDC_COMBOCLASS, m_comboclass);
DDX_Control(pDX, IDC_LISTSEARCH, m_listsearch);
DDX_Text(pDX, IDC_SEARCHNAME, m_searchname);
DDX_Text(pDX, IDC_SEARCHNO, m_searchno);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSubForm1, CFormView)
//{{AFX_MSG_MAP(CSubForm1)
ON_CBN_SELENDOK(IDC_COMBOCLASS, OnSelendokComboclass)
ON_CBN_SELENDOK(IDC_COMBOCOURSE, OnSelendokCombocourse)
ON_CBN_SELENDOK(IDC_COMBOYEAR, OnSelendokComboyear)
ON_CBN_SELENDOK(IDC_COMBOZHUANYIE, OnSelendokCombozhuanyie)
ON_BN_CLICKED(IDC_BUTTONSEARCH, OnButtonsearch)
ON_BN_CLICKED(IDC_BUTTONREFRESH, OnButtonrefresh)
//}}AFX_MSG_MAP
ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CFormView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSubForm1 diagnostics
#ifdef _DEBUG
void CSubForm1::AssertValid() const
{
CFormView::AssertValid();
}
void CSubForm1::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
CMyDoc* CSubForm1::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMyDoc)));
return (CMyDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CSubForm1 message handlers
BOOL CSubForm1::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
return CFormView::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
}
void CSubForm1::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
// TODO: Add your specialized code here and/or call the base class
LONG lStyle = m_listsearch.SendMessage(LVM_GETEXTENDEDLISTVIEWSTYLE);
lStyle |= LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_HEADERDRAGDROP;
m_listsearch.SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE, 0,(LPARAM)lStyle);
int left=0;
CString feild[7]={"学号","姓名","课程","成绩","班级","专业","学期"};
for(int i=0;i<7;i++)
{
m_listsearch.InsertColumn(i+1,feild[i],left,100,i);
left=200*(i+1);
}
//显示
m_studentset.m_strSort="学号";
m_studentset.Open();
m_classset.Open();
m_courseset.Open();
m_gradeset.Open();
BOOL courseno;
m_listsearch.DeleteAllItems();
CString grade,coursename,courseyear;
int j=0;
m_classset.MoveFirst();
do
{
m_studentset.MoveFirst();
do
{
if(m_studentset.m_column3==m_classset.m_column1)
{
m_gradeset.MoveFirst();
do
{
courseno=FALSE;
if(m_gradeset.m_column1==m_studentset.m_column1)
{
m_courseset.MoveFirst();
do
{
if(m_gradeset.m_column2==m_courseset.m_column1)
{
courseno=TRUE;
coursename=m_courseset.m_column2;
courseyear=m_courseset.m_column4;
break;
}
m_courseset.MoveNext();
}while (!m_courseset.IsEOF());
if(courseno)
{
m_listsearch.InsertItem(j,m_gradeset.m_column1,0);
m_listsearch.SetItemText(j,1,m_studentset.m_column2);
m_listsearch.SetItemText(j,2,coursename);
m_listsearch.SetItemText(j,6,courseyear);
grade.Format("%4.2f",double(m_gradeset.m_column3));
m_listsearch.SetItemText(j,3,grade);
m_listsearch.SetItemText(j,4,m_classset.m_column2);
m_listsearch.SetItemText(j,5,m_classset.m_column3);
j++;
}
}
m_gradeset.MoveNext();
}while(!m_gradeset.IsEOF());
}
m_studentset.MoveNext();
}while(!m_studentset.IsEOF());
m_classset.MoveNext();
}while(!m_classset.IsEOF());
m_studentset.Close();
m_classset.Close();
m_courseset.Close();
m_gradeset.Close();
int num;
num=m_listsearch.GetItemCount();
if(num==0)
MessageBox("没有记录");
//combo
m_combozhuanyie.ResetContent();
m_classset.Open();
BOOL zhuanyie;
BOOL xueqi;
CString s;
m_classset.MoveFirst();
do
{
zhuanyie=TRUE;
for (j=0;j<m_combozhuanyie.GetCount();j++)
{
m_combozhuanyie.GetLBText(j,s);
if(m_classset.m_column3==s)
{
zhuanyie=FALSE;
}
}
if(zhuanyie)
{
m_combozhuanyie.AddString(m_classset.m_column3);
}
m_comboclass.AddString(m_classset.m_column2);
m_classset.MoveNext();
} while(!m_classset.IsEOF());
m_classset.Close();
//
if(!m_courseset.IsOpen())
m_courseset.Open();
if(!m_courseset.IsBOF())
m_courseset.MoveFirst();
do
{
xueqi=TRUE;
for (j=0;j<m_comboyear.GetCount();j++)
{
m_comboyear.GetLBText(j,s);
if(m_courseset.m_column4==s)
{
xueqi=FALSE;
}
}
if(xueqi)
{
m_comboyear.AddString(m_courseset.m_column4);
}
m_combocourse.AddString(m_courseset.m_column2);
m_courseset.MoveNext();
} while (!m_courseset.IsEOF());
if(m_courseset.IsOpen())
m_courseset.Close();
}
void CSubForm1::OnDraw(CDC* pDC)
{
// TODO: Add your specialized code here and/or call the base class
CWnd*parent=GetParent();
CMenu*pmenubar=parent->GetMenu();
CMenu*pmenu=pmenubar->GetSubMenu(0);
pmenu->SetMenuItemBitmaps(0,MF_BYPOSITION,&dayin1,&dayin2);
pmenu->SetMenuItemBitmaps(1,MF_BYPOSITION,&preview1,&preview2);
}
void CSubForm1::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: Add your specialized code here and/or call the base class
// CFormView::OnBeginPrinting(pDC, pInfo);
}
void CSubForm1::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: Add your specialized code here and/or call the base class
// CFormView::OnEndPrinting(pDC, pInfo);
}
void CSubForm1::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{
// TODO: Add your specialized code here and/or call the base class
OutputReport(pDC, pInfo);
}
BOOL CSubForm1::OnPreparePrinting(CPrintInfo* pInfo)
{
// TODO: call DoPreparePrinting to invoke the Print dialog box
return DoPreparePrinting(pInfo);
// return CFormView::OnPreparePrinting(pInfo);
}
void CSubForm1::OnSelendokComboclass()
{
m_studentset.m_strFilter="";
m_classset.m_strFilter="";
m_courseset.m_strFilter="";
// TODO: Add your control notification handler code here
CString currentzhuanyie;
CString currentyear;
CString currentclass;
CString currentcourse,str;
CString strclass,strzhuanyie,stryear,strcourse;
if(m_comboyear.GetCurSel()>=0)
m_comboyear.GetLBText(m_comboyear.GetCurSel(),currentyear);
if(m_combozhuanyie.GetCurSel()>=0)
m_combozhuanyie.GetLBText(m_combozhuanyie.GetCurSel(),currentzhuanyie);
if(m_comboclass.GetCurSel()>=0)
m_comboclass.GetLBText(m_comboclass.GetCurSel(),currentclass);
if(m_combocourse.GetCurSel()>=0)
m_combocourse.GetLBText(m_combocourse.GetCurSel(),currentcourse);
strzhuanyie="专业名";
strclass="班级名";
stryear="学期";
strcourse="课程名";
if(currentzhuanyie=="" && currentclass=="")
{
m_classset.m_strFilter="";
}
else if(currentzhuanyie!="" && currentclass=="")
{
m_classset.m_strFilter=strzhuanyie+"='"+currentzhuanyie+"'";
}
else if(currentzhuanyie=="" && currentclass!="")
{
m_classset.m_strFilter=strclass + "='" + currentclass + "'";
}
else
{
m_classset.m_strFilter=strzhuanyie + "='" + currentzhuanyie + "'" + "AND " + strclass + "='" + currentclass + "'";
}
if(currentyear=="" && currentcourse=="")
{
m_courseset.m_strFilter="";
}
else if(currentyear!="" && currentcourse=="")
{
m_courseset.m_strFilter=stryear + "='" + currentyear + "'";
}
else if(currentyear=="" && currentcourse!="")
{
m_courseset.m_strFilter=strcourse + "='" + currentcourse + "'";
}
else
{
str=stryear + "='" + currentyear+"'" + "AND " + strcourse + "='" + currentcourse+"'";
m_courseset.m_strFilter=str;
}
/////////////
m_studentset.Open();
m_classset.Open();
m_courseset.Open();
m_gradeset.Open();
BOOL courseno;
m_listsearch.DeleteAllItems();
CString grade,coursename,courseyear;
int j=0;
m_classset.MoveFirst();
do
{
m_studentset.MoveFirst();
do
{
if(m_studentset.m_column3==m_classset.m_column1)
{
m_gradeset.MoveFirst();
do
{
courseno=FALSE;
if(m_gradeset.m_column1==m_studentset.m_column1)
{
m_courseset.MoveFirst();
do
{
if(m_gradeset.m_column2==m_courseset.m_column1)
{
courseno=TRUE;
coursename=m_courseset.m_column2;
courseyear=m_courseset.m_column4;
break;
}
m_courseset.MoveNext();
}while (!m_courseset.IsEOF());
if(courseno)
{
m_listsearch.InsertItem(j,m_gradeset.m_column1,0);
m_listsearch.SetItemText(j,1,m_studentset.m_column2);
m_listsearch.SetItemText(j,2,coursename);
m_listsearch.SetItemText(j,6,courseyear);
grade.Format("%4.2f",double(m_gradeset.m_column3));
m_listsearch.SetItemText(j,3,grade);
m_listsearch.SetItemText(j,4,m_classset.m_column2);
m_listsearch.SetItemText(j,5,m_classset.m_column3);
j++;
}
}
m_gradeset.MoveNext();
}while(!m_gradeset.IsEOF());
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -