📄 smedlg.cpp
字号:
// SMEDlg.cpp : 实现文件
//
#include "stdafx.h"
#include "DBLogin.h"
#include "SMEDlg.h"
#include "test.h"
#include "score.h"
#include "testTemp.h"
#include ".\smedlg.h"
// SMEDlg 对话框
IMPLEMENT_DYNAMIC(SMEDlg, CDialog)
SMEDlg::SMEDlg(CWnd* pParent /*=NULL*/)
: CDialog(SMEDlg::IDD, pParent)
, m_Tester(_T(""))
, m_UserAnswer(_T(""))
, m_Score(0)
, m_Question(_T(""))
, m_Answer_A(_T(""))
, m_Answer_B(_T(""))
, m_Answer_C(_T(""))
, m_Answer_D(_T(""))
, m_SME_Commnet(_T(""))
{
pDB = new CDatabase();
try{
if(!pDB->OpenEx("DSN=test"))
AfxMessageBox("Error,Can't open database");
pSet = new Ctest(pDB);
pSet->Open(CRecordset::dynaset);
}catch(CException *e){
e->ReportError();
}
pTDB = new CDatabase();
try{
if(!pTDB->OpenEx("DSN=testTemp"))
AfxMessageBox("Error,Can't open database");
pTSet = new CtestTemp(pTDB);
pTSet->Open(CRecordset::dynaset);
}catch(CException *e){
e->ReportError();
}
pDBs = new CDatabase();
try{
if(!pDBs->OpenEx("DSN=score"))
AfxMessageBox("Error,Can't open database");
pSets = new Cscore(pDBs);
pSets->Open(CRecordset::dynaset);
}catch(CException *e){
e->ReportError();
}
pSets->MoveFirst();
this->m_Tester = pSets->m_ID;
this->GetTest();
this->SetAnswer();
this->SetTest();
this->m_SME_Commnet=pSets->m_Comment;
}
SMEDlg::~SMEDlg()
{
if(pDB->IsOpen())
pDB->Close();
if(pTDB->IsOpen())
pTDB->Close();
if(pDBs->IsOpen())
pDBs->Close();
if(pSet->IsOpen())
pSet->Close();
if(pTSet->IsOpen())
pTSet->Close();
if(pSets->IsOpen())
pSets->Close();
delete pDB;
delete pTDB;
delete pDBs;
delete pSet;
delete pTSet;
delete pSets;
}
void SMEDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_Tester, m_Tester);
DDX_Text(pDX, IDC_UserAnswer, m_UserAnswer);
DDX_Text(pDX, IDC_Tester3, m_Score);
DDX_Text(pDX, IDC_EDIT2, m_Question);
DDX_Text(pDX, IDC_A, m_Answer_A);
DDX_Text(pDX, IDC_B, m_Answer_B);
DDX_Text(pDX, IDC_C, m_Answer_C);
DDX_Text(pDX, IDC_D, m_Answer_D);
DDX_Text(pDX, IDC_EDIT6, m_SME_Commnet);
}
void SMEDlg::GetTest()
{
int i(0);
this->Question[0]=pSets->m_Question1;
this->Question[1]=pSets->m_Question2;
this->Question[2]=pSets->m_Question3;
this->Question[3]=pSets->m_Question4;
this->Question[4]=pSets->m_Question5;
for(pTSet->MoveFirst();!pTSet->IsEOF();pTSet->MoveNext())
{
if(pTSet->CanUpdate())
{
pSet->SetAbsolutePosition(this->Question[i]);
pTSet->Edit();
pTSet->m_Question = pSet->m_Question;
pTSet->m_A = pSet->m_A;
pTSet->m_B = pSet->m_B;
pTSet->m_C = pSet->m_C;
pTSet->m_D = pSet->m_D;
pTSet->Update();
}else
AfxMessageBox("Error to get test");
i++;
}
pTSet->MoveFirst();
}
void SMEDlg::SetAnswer()
{
A[0]=pSets->m_Answer1;
A[1]=pSets->m_Answer2;
A[2]=pSets->m_Answer3;
A[3]=pSets->m_Answer4;
A[4]=pSets->m_Answer5;
}
void SMEDlg::SetTest()
{
//this->m_Score = pTSet->m_Score;
this->m_Question = pTSet->m_Question;
this->m_Answer_A = pTSet->m_A;
this->m_Answer_B = pTSet->m_B;
this->m_Answer_C = pTSet->m_C;
this->m_Answer_D = pTSet->m_D;
this->m_UserAnswer = A[pTSet->m_ID-1];
}
BEGIN_MESSAGE_MAP(SMEDlg, CDialog)
ON_BN_CLICKED(IDC_BUTTON3, OnBnClickedButton3)
ON_BN_CLICKED(IDC_BUTTON4, OnBnClickedButton4)
ON_BN_CLICKED(IDC_BUTTON5, OnBnClickedButton5)
ON_BN_CLICKED(IDC_BUTTON6, OnBnClickedButton6)
ON_BN_CLICKED(IDFIRST, OnBnClickedFirst)
ON_BN_CLICKED(IDPREV, OnBnClickedPrev)
ON_BN_CLICKED(IDNEXT, OnBnClickedNext)
ON_BN_CLICKED(IDEND, OnBnClickedEnd)
ON_BN_CLICKED(IDOK, OnBnClickedOk)
END_MESSAGE_MAP()
// SMEDlg 消息处理程序
void SMEDlg::OnBnClickedButton3()
{
// TODO: 在此添加控件通知处理程序代码
pSets->MoveFirst();
this->m_Tester = pSets->m_ID;
this->GetTest();
this->SetAnswer();
this->SetTest();
this->m_Score = pSets->m_Score;
this->m_SME_Commnet=pSets->m_Comment;
UpdateData(false);
}
void SMEDlg::OnBnClickedButton4()
{
// TODO: 在此添加控件通知处理程序代码
pSets->MovePrev();
if(pSets->IsBOF())
pSets->MoveFirst();
this->m_Tester = pSets->m_ID;
this->GetTest();
this->SetAnswer();
this->SetTest();
this->m_Score = pSets->m_Score;
this->m_SME_Commnet=pSets->m_Comment;
UpdateData(false);
}
void SMEDlg::OnBnClickedButton5()
{
// TODO: 在此添加控件通知处理程序代码
pSets->MoveNext();
if(pSets->IsEOF())
pSets->MoveLast();
this->m_Tester = pSets->m_ID;
this->GetTest();
this->SetAnswer();
this->SetTest();
this->m_Score = pSets->m_Score;
this->m_SME_Commnet=pSets->m_Comment;
UpdateData(false);
}
void SMEDlg::OnBnClickedButton6()
{
// TODO: 在此添加控件通知处理程序代码
pSets->MoveLast();
this->m_Tester = pSets->m_ID;
this->GetTest();
this->SetAnswer();
this->SetTest();
this->m_Score = pSets->m_Score;
this->m_SME_Commnet=pSets->m_Comment;
UpdateData(false);
}
void SMEDlg::OnBnClickedFirst()
{
// TODO: 在此添加控件通知处理程序代码
pTSet->MoveFirst();
this->SetTest();
UpdateData(false);
}
void SMEDlg::OnBnClickedPrev()
{
// TODO: 在此添加控件通知处理程序代码
pTSet->MovePrev();
if(pTSet->IsBOF())
pTSet->MoveFirst();
this->SetTest();
UpdateData(false);
}
void SMEDlg::OnBnClickedNext()
{
// TODO: 在此添加控件通知处理程序代码
pTSet->MoveNext();
if(pTSet->IsEOF())
pTSet->MoveLast();
this->SetTest();
UpdateData(false);
}
void SMEDlg::OnBnClickedEnd()
{
// TODO: 在此添加控件通知处理程序代码
pTSet->MoveLast();
this->SetTest();
UpdateData(false);
}
void SMEDlg::OnBnClickedOk()
{
// TODO: 在此添加控件通知处理程序代码
//OnOK();
UpdateData(true);
if(pSets->CanUpdate())
{
pSets->Edit();
pSets->m_Comment = this->m_SME_Commnet;
pSets->Update();
AfxMessageBox("该生评注已提交");
}else
AfxMessageBox("评注提交失败");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -