📄 adminquerystudentscoredlg.cpp
字号:
// AdminQueryStudentScoreDlg.cpp : implementation file
//
#include "stdafx.h"
#include "学生成绩管理系统.h"
//以下是手工添加的的
#include "ScoresRS1.h"
//以上是手工添加的
#include "AdminQueryStudentScoreDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAdminQueryStudentScoreDlg dialog
CAdminQueryStudentScoreDlg::CAdminQueryStudentScoreDlg(CWnd* pParent /*=NULL*/)
: CDialog(CAdminQueryStudentScoreDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CAdminQueryStudentScoreDlg)
m_adminQueryStudentSubject = _T("");
m_adminQueryStudentID = _T("");
m_queryCondition = 0;
//}}AFX_DATA_INIT
}
void CAdminQueryStudentScoreDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAdminQueryStudentScoreDlg)
DDX_Control(pDX, IDC_ADMIN_QUERY_RESULT, m_adminQueryResult);
DDX_Text(pDX, IDC_ADMIN_QUERY_STUDENT_SUBJECT, m_adminQueryStudentSubject);
DDX_Text(pDX, IDC_ADMN_QUERY_STUDENT_SCORE_ID, m_adminQueryStudentID);
DDX_Radio(pDX, IDC_QUERY_CONDITION, m_queryCondition);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAdminQueryStudentScoreDlg, CDialog)
//{{AFX_MSG_MAP(CAdminQueryStudentScoreDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAdminQueryStudentScoreDlg message handlers
void CAdminQueryStudentScoreDlg::OnOK()
{
// TODO: Add extra validation here
try{
int error1=0;
float error2=0;
double error3=0;
UpdateData();
CString table1("科目:");
CString table2("; 成绩是:");
CString table3("; 绩点是:");
CString content;
CString temp;
if (!m_scoresSet.IsOpen())
{
m_scoresSet.Open();
}
switch(m_queryCondition)
{
case 0:
if(m_adminQueryStudentID=="")
throw error1;
m_scoresSet.m_strFilter.Format("ID='%s'",m_adminQueryStudentID);
break;
case 1:
if(m_adminQueryStudentSubject=="")
throw error2;
m_scoresSet.m_strFilter.Format("subject='%s'",m_adminQueryStudentSubject);
break;
case 2:
if(!(m_adminQueryStudentID!=""&&m_adminQueryStudentSubject!=""))
throw error3;
m_scoresSet.m_strFilter.Format("ID='%s' and subject='%s'",m_adminQueryStudentID,m_adminQueryStudentSubject);
break;
default:
break;
}
m_scoresSet.Requery();
m_adminQueryResult.ResetContent();
if (m_scoresSet.IsEOF()){
AfxMessageBox("没有记录!");
}
else if(m_queryCondition==0)//query by id
{
// m_adminQueryResult.ResetContent();
while (!m_scoresSet.IsEOF())
{
content.Empty();
temp.Empty();
content+=table1;//subject
content+=m_scoresSet.m_subject;
content+=table2;//score
temp.Format("%d",m_scoresSet.m_score);
content+=temp;
content+=table3;//credit
content+=m_scoresSet.m_credit;
m_adminQueryResult.AddString(content);
SendDlgItemMessage(IDC_ADMIN_QUERY_RESULT, LB_SETHORIZONTALEXTENT, 1200, 0); // 设置长度为1200像素的水平滚动条
m_scoresSet.MoveNext();
}
}
else if(m_queryCondition==1)
{
// m_adminQueryResult.ResetContent();
CString ID("学号:");
while (!m_scoresSet.IsEOF())
{
content.Empty();
temp.Empty();
content+=ID;
content+=m_scoresSet.m_ID;
content+=table2;//score
temp.Format("%d",m_scoresSet.m_score);
content+=temp;
content+=table3;//credit
content+=m_scoresSet.m_credit;
m_adminQueryResult.AddString(content);
SendDlgItemMessage(IDC_ADMIN_QUERY_RESULT, LB_SETHORIZONTALEXTENT, 1200, 0); // 设置长度为1200像素的水平滚动条
m_scoresSet.MoveNext();
}
}
else if(m_queryCondition==2)
{
CString tempTable("成绩是:");
// m_adminQueryResult.ResetContent();
while (!m_scoresSet.IsEOF())
{
content.Empty();
temp.Empty();
content+=tempTable;//score
temp.Format("%d",m_scoresSet.m_score);
content+=temp;
content+=table3;//credit
content+=m_scoresSet.m_credit;
m_adminQueryResult.AddString(content);
SendDlgItemMessage(IDC_ADMIN_QUERY_RESULT, LB_SETHORIZONTALEXTENT, 1200, 0); // 设置长度为1200像素的水平滚动条
m_scoresSet.MoveNext();
}
}
}
catch(int)
{
AfxMessageBox("输入学号的学号不能为空!");
}
catch(float)
{
AfxMessageBox("输入的科目为空!");
}
catch(double)
{
AfxMessageBox("输入的学号、科目皆不能为空!");
}
// CDialog::OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -