📄 lrdialog.cpp
字号:
// LrDialog.cpp : implementation file
//
#include "stdafx.h"
#include "TestPaper.h"
#include "LrDialog.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CLrDialog dialog
CLrDialog::CLrDialog(CWnd* pParent /*=NULL*/)
: CDialog(CLrDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CLrDialog)
m_edit4 = _T("");
m_edit8 = _T("");
m_edit1 = _T("");
m_edit5 = _T("");
m_edit6 = _T("");
m_edit9 = _T("");
m_edit7 = _T("");
//}}AFX_DATA_INIT
}
void CLrDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CLrDialog)
DDX_Control(pDX, IDC_COMBO2, m_box2);
DDX_Control(pDX, IDC_EDIT8, m_Conedit8);
DDX_Control(pDX, IDC_COMBO1, m_box1);
DDX_Text(pDX, IDC_EDIT4, m_edit4);
DDX_Text(pDX, IDC_EDIT8, m_edit8);
DDX_Text(pDX, IDC_EDIT1, m_edit1);
DDX_Text(pDX, IDC_EDIT5, m_edit5);
DDX_Text(pDX, IDC_EDIT6, m_edit6);
DDX_Text(pDX, IDC_EDIT9, m_edit9);
DDX_Text(pDX, IDC_EDIT7, m_edit7);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CLrDialog, CDialog)
//{{AFX_MSG_MAP(CLrDialog)
ON_EN_CHANGE(IDC_EDIT8, OnChangeEdit8)
ON_EN_CHANGE(IDC_EDIT2, OnChangeEdit2)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLrDialog message handlers
BOOL CLrDialog::OnInitDialog() //初始化
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CString cstr1;
CString cstr2;
HICON hIcon=AfxGetApp()->LoadIcon(IDI_ICON12);
this->SendMessage(WM_SETICON,ICON_BIG,(LPARAM)hIcon);
CMainFrame* pMainFrame=(CMainFrame*) AfxGetMainWnd();
CStdioFile MyFile;
CString str;
MyFile.Open("外部接口\\题库管理之考试对象.txt",CFile::modeRead|CFile::typeText);
MyFile.SeekToBegin();
while(MyFile.ReadString(str))
{
if(str!="")
{
m_box2.AddString(str);
str.Empty();
}
}
MyFile.Close();
int nIndex1 = pMainFrame->m_wndAddress1.GetCurSel();
int nIndex2 = pMainFrame->m_wndAddress2.GetCurSel();
pMainFrame->m_wndAddress1.GetLBText(nIndex1,cstr1);
cstr1.TrimLeft(" ");
pMainFrame->m_wndAddress2.GetLBText(nIndex2,cstr2);
cstr2.TrimLeft(" ");
if(pMainFrame->m_recordset.IsOpen())
{
if(pMainFrame->m_recordset.GetRecordCount()==0)
{
m_edit1="1";
}
else
{
CDBVariant OleVar;
pMainFrame->m_recordset.MoveFirst();
int wo=0;
pMainFrame->m_recordset.GetFieldValue(wo,OleVar);
int max=OleVar.m_iVal;
for(int j=1;j<pMainFrame->m_recordset.GetRecordCount();j++)
{
pMainFrame->m_recordset.MoveNext();
pMainFrame->m_recordset.GetFieldValue(wo,OleVar);
int BiJiao=OleVar.m_iVal;
if(BiJiao>max)
max=BiJiao;
}
char buf[20];
itoa(max+1,buf,10);
m_edit1=buf;
}
shistr=m_edit1;
}
UpdateData(FALSE);
GetDlgItem(IDC_EDIT1)->EnableWindow(true);
m_box1.SetCurSel(2);
m_box2.SetCurSel(0);
if(pMainFrame->BoolConnent==FALSE)
{
GetDlgItem(IDC_BUTTON2)->EnableWindow(false);
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CLrDialog::OnChangeEdit8()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
}
void CLrDialog::OnChangeEdit2()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
}
void CLrDialog::OnButton2() //添加题目
{
// TODO: Add your control notification handler code here
CTestPaperApp* pApp=(CTestPaperApp*) AfxGetApp();
UpdateData(TRUE);
CMainFrame* pMainFrame=(CMainFrame*) AfxGetMainWnd();
if(!pMainFrame->m_recordset.CanUpdate())
return;
CString cstr1;
CString cstr2;
int nIndex1 = pMainFrame->m_wndAddress1.GetCurSel();
int nIndex2 = pMainFrame->m_wndAddress2.GetCurSel();
pMainFrame->m_wndAddress1.GetLBText(nIndex1,cstr1);
cstr1.TrimLeft(" ");
pMainFrame->m_wndAddress2.GetLBText(nIndex2,cstr2);
cstr2.TrimLeft(" ");
CString tempstr2;
m_box2.GetLBText(m_box2.GetCurSel(),tempstr2);
CString tempstr;
m_box1.GetLBText(m_box1.GetCurSel(),tempstr);
if(atoi(m_edit1)<=0)
{
AfxMessageBox("请输入正确的题目编号值!");
return;
}
if(m_edit5=="")
{
m_edit5=" ";
}
if(m_edit9=="")
{
m_edit9=" ";
}
if(m_edit7=="")
{
m_edit7=" ";
}
if(m_edit4=="")
{
m_edit4=" ";
}
if(m_edit8=="")
{
m_edit8=" ";
}
if(m_edit6=="")
{
m_edit6=" ";
}
try
{
CString strSQL;
strSQL.Empty();
strSQL.Format("insert into %s%s(题目编号,考试对象,难度级别,题目内容,选项A,选项B,选项C,选项D,标准答案,用户名,识别号) values('"+m_edit1+"','"+tempstr2+"','"
+tempstr+"','"+m_edit5+"','"+m_edit9+"','"+m_edit7+"','"
+m_edit4+"','"+m_edit8+"','"+m_edit6+"','"
+pApp->enterdlg.struser+"','"+shistr+"')",cstr1,cstr2);
pMainFrame->m_database.ExecuteSQL(strSQL);
}
catch(...)
{
AfxMessageBox("出现异常!");
return;
}
pMainFrame->Refreshdata();
CDialog::OnOK();
CLrDialog dg;
dg.DoModal();
}
void CLrDialog::OnButton3()
{
// TODO: Add your control notification handler code here
CDialog::OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -