📄 scorequery.cpp
字号:
// ScoreQuery.cpp : implementation file
//
#include "stdafx.h"
#include "sm.h"
#include "score.h"
#include "scorelist.h"
#include "UnitclassTree.h"
#include "ScoreQuery.h"
#include "ScorePrintDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CScoreQuery dialog
//##ModelId=40A481F40243
CScoreQuery::CScoreQuery(CWnd* pParent /*=NULL*/)
: CDialog(CScoreQuery::IDD, pParent)
{
//{{AFX_DATA_INIT(CScoreQuery)
//}}AFX_DATA_INIT
}
//##ModelId=40A481F402AF
void CScoreQuery::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CScoreQuery)
DDX_Control(pDX, IDC_TREE1, m_Tree);
DDX_Control(pDX, IDC_STUDENT_COMBO, m_Student);
DDX_Control(pDX, IDC_LIST4, m_List);
DDX_Control(pDX, IDC_DTPICKER1, m_Begin);
DDX_Control(pDX, IDC_DTPICKER2, m_End);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CScoreQuery, CDialog)
//{{AFX_MSG_MAP(CScoreQuery)
ON_BN_CLICKED(IDC_BUTTON_PRINT, OnButtonPrint)
ON_WM_DESTROY()
ON_NOTIFY(TVN_SELCHANGED, IDC_TREE1, OnSelchangedTree)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CScoreQuery message handlers
//##ModelId=40A481F402BF
void CScoreQuery::OnOK()
{
if(pTree->GetSelectType()!=1)
{
AfxMessageBox("请选择一个班级及学生!!");
return;
}
LoadScore();
// CDialog::OnOK();
}
//##ModelId=40A481F402C1
void CScoreQuery::OnButtonPrint()
{
OnOK();
if(pTree->GetSelectType()!=1)
return;
CString s = pTree->GetSelectClass().GetTeacherName();
CScorePrintDlg dlg(pList, &pTree->GetSelectClass().Title, &s);
dlg.DoModal();
}
//##ModelId=40A481F402CF
void CScoreQuery::OnDestroy()
{
CDialog::OnDestroy();
// TODO: Add your message handler code here
}
//##ModelId=40A481F402D1
BOOL CScoreQuery::OnInitDialog()
{
CDialog::OnInitDialog();
pTree = new UnitClassTree(&m_Tree);
pTree->Load();
pTree->ExpandRoot();
pTree->SetSelectUnit(1);
pList = new ScoreList(&m_List);
pList->Init();
CTime t = CTime::GetCurrentTime();
CTimeSpan cts(60, 0, 0, 0);
m_End.SetYear(COleVariant((short)t.GetYear()));
m_End.SetMonth(COleVariant((short)t.GetMonth()));
m_End.SetDay(COleVariant((short)t.GetDay()));
t -= cts;
m_Begin.SetYear(COleVariant((short)t.GetYear()));
m_Begin.SetMonth(COleVariant((short)t.GetMonth()));
m_Begin.SetDay(COleVariant((short)t.GetDay()));
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
//##ModelId=40A481F402DF
void CScoreQuery::OnSelchangedTree(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
// TODO: Add your control notification handler code here
if(pTree->GetSelectType()==1)
{
LoadStudent(pTree->GetSelectClass().ID);
}
else
{
while(m_Student.GetCount()!=0)
m_Student.DeleteString(0);
}
*pResult = 0;
}
//##ModelId=40A481F40234
void CScoreQuery::LoadStudent(long class_id)
{
while(m_Student.GetCount()!=0)
m_Student.DeleteString(0);
Students.clear();
CDaoTableDef td(&theDatabase);
td.Open("student");
CDaoRecordset rs;
rs.Open(&td);
rs.SetCurrentIndex("class_id");
if(rs.Seek("=", &COleVariant(class_id)))
{
while(!rs.IsEOF())
{
if(rs.GetFieldValue("class_id").lVal!=class_id)
break;
Students.push_back(Student(rs.GetFieldValue("ID").lVal,
V_BSTRT(&rs.GetFieldValue("name")),
rs.GetFieldValue("sex").boolVal==-1,
rs.GetFieldValue("birthday"),
rs.GetFieldValue("class_id").lVal,
rs.GetFieldValue("number").lVal,
V_BSTRT(&rs.GetFieldValue("email")),
V_BSTRT(&rs.GetFieldValue("remark"))
)
);
rs.MoveNext();
}
}
rs.Close();
td.Close();
int i=0;
for(vector<Student>::iterator iter=Students.begin(); iter!=Students.end();iter++)
{
m_Student.AddString(iter->Name);
m_Student.SetItemData(i++, iter->ID);
}
m_Student.SetCurSel(0);
}
//##ModelId=40A481F40233
void CScoreQuery::LoadScore()
{
COleDateTime bt(m_Begin.GetYear().intVal, m_Begin.GetMonth().intVal, m_Begin.GetDay().intVal, 0, 0, 0);
COleDateTime et(m_End.GetYear().intVal, m_End.GetMonth().intVal, m_End.GetDay().intVal, 23, 59, 59);
if(m_Student.GetCurSel()!=CB_ERR )
{
long s_id = m_Student.GetItemData(m_Student.GetCurSel());
pList->Load(bt.Format("%Y-%m-%d %H:%M:%S"), et.Format("%Y-%m-%d %H:%M:%S"), s_id);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -