📄 xindialog.cpp
字号:
// XinDialog.cpp : implementation file
//
#include "stdafx.h"
#include "TestPaper.h"
#include "XinDialog.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CXinDialog dialog
CString num;
CXinDialog::CXinDialog(CWnd* pParent /*=NULL*/)
: CDialog(CXinDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CXinDialog)
m_xinbox2 = _T("");
m_xinbox3 = _T("");
m_xinedit1 = _T("");
m_xinedit2 = _T("");
m_xinedit3 = _T("");
m_xinedit4 = _T("");
m_xinedit5 = _T("");
m_xinedit6 = _T("");
m_xinedit7 = _T("");
m_xinbox1 = _T("");
//}}AFX_DATA_INIT
}
void CXinDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CXinDialog)
DDX_Control(pDX, IDC_COMBO3, m_controlxinbox3);
DDX_Control(pDX, IDC_COMBO2, m_controlxinbox2);
DDX_Control(pDX, IDC_COMBO1, m_controlxinbox1);
DDX_CBString(pDX, IDC_COMBO2, m_xinbox2);
DDX_CBString(pDX, IDC_COMBO3, m_xinbox3);
DDX_Text(pDX, IDC_EDIT1, m_xinedit1);
DDX_Text(pDX, IDC_EDIT2, m_xinedit2);
DDX_Text(pDX, IDC_EDIT3, m_xinedit3);
DDX_Text(pDX, IDC_EDIT4, m_xinedit4);
DDX_Text(pDX, IDC_EDIT5, m_xinedit5);
DDX_Text(pDX, IDC_EDIT6, m_xinedit6);
DDX_Text(pDX, IDC_EDIT7, m_xinedit7);
DDX_CBString(pDX, IDC_COMBO1, m_xinbox1);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CXinDialog, CDialog)
//{{AFX_MSG_MAP(CXinDialog)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CXinDialog message handlers
BOOL CXinDialog::OnInitDialog()
{
CDialog::OnInitDialog();
CMainFrame* pMainFrame=(CMainFrame*) AfxGetMainWnd();
// TODO: Add extra initialization here
HICON hIcon=AfxGetApp()->LoadIcon(IDI_ICON17);
this->SendMessage(WM_SETICON,ICON_BIG,(LPARAM)hIcon);
CStdioFile MyFile;
CString str;
CTime tm;
MyFile.Open("外部接口\\题库管理之学科名称.txt",CFile::modeRead|CFile::typeText);
MyFile.SeekToBegin();
while(MyFile.ReadString(str))
{
if(str!="")
{
m_controlxinbox1.AddString(str);
str.Empty();
}
}
MyFile.Close();
MyFile.Open("外部接口\\题库管理之考试对象.txt",CFile::modeRead|CFile::typeText);
MyFile.SeekToBegin();
while(MyFile.ReadString(str))
{
if(str!="")
{
m_controlxinbox2.AddString(str);
str.Empty();
}
}
MyFile.Close();
CString strtm;
tm=CTime::GetCurrentTime();
strtm.Format("%d-%d-%d %d:%d:%d",tm.GetYear(),tm.GetMonth(),tm.GetDay(),tm.GetHour(),tm.GetMinute(),tm.GetSecond());
this->m_controlxinbox1.SetCurSel(0);
this->m_controlxinbox2.SetCurSel(0);
this->m_controlxinbox3.SetCurSel(2);
UpdateData(TRUE);
m_xinedit7=strtm+m_xinbox2+m_xinbox1+"高级考试";
comstr1=m_xinedit7;
m_xinedit2="当前时间";
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CXinDialog::OnButton2()
{
// TODO: Add your control notification handler code here
CDialog::OnOK();
}
void CXinDialog::OnButton1() //试卷参数设置函数
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
comstr2=m_xinedit7;
if(atoi(m_xinedit1)<1 || atoi(m_xinedit3)<1 || atoi(m_xinedit4)<1 ||atof(m_xinedit5)<1 || atof(m_xinedit6)<1)
{
AfxMessageBox("请输入正确的整数值!");
return;
}
if(m_xinedit7=="")
{
AfxMessageBox("请输入正确的字符串,不可为空!");
return;
}
CTime time;
CMainFrame* pMainFrame=(CMainFrame*) AfxGetMainWnd();
try
{
if(pMainFrame->m_yangrecordset.IsOpen())
{
pMainFrame->m_yangrecordset.Close();
pMainFrame->m_yangrecordset.Open(CRecordset::dynaset,"select * from 试卷参数设置");
}
else
{
pMainFrame->m_yangrecordset.Open(CRecordset::dynaset,"select * from 试卷参数设置");
}
}
catch(...)
{
AfxMessageBox("cann't open table!");
return;
}
if(!pMainFrame->m_yangrecordset.CanUpdate())
{
AfxMessageBox("不可更新!");
return;
}
if(pMainFrame->m_yangrecordset.GetRecordCount()==0)
{
num="1";
}
else
{
CDBVariant OleVar;
int bo=0;
pMainFrame->m_yangrecordset.MoveFirst();
pMainFrame->m_yangrecordset.GetFieldValue(bo,OleVar);
int max=OleVar.m_iVal;
pMainFrame->m_yangrecordset.MoveNext();
if(!pMainFrame->m_yangrecordset.IsEOF())
{
int bi=0;
pMainFrame->m_yangrecordset.GetFieldValue(bi,OleVar);
int BiJiao=OleVar.m_iVal;
if(BiJiao>max)
{
max=BiJiao;
}
}
char buf[20];
itoa(max+1,buf,10);
num=buf;
}
CString strtime;
time=CTime::GetCurrentTime();
strtime.Format("%d-%d-%d %d:%d:%d",time.GetYear(),time.GetMonth(),time.GetDay(),time.GetHour(),time.GetMinute(),time.GetSecond());
CString str2;
int value;
value=atoi(m_xinbox3);
if(value==1)
{
str2="低级";
}
if(value==2)
{
str2="中级";
}
if(value==3)
{
str2="高级";
}
if(m_xinedit7.Compare(comstr1)==0)
{
m_xinedit7=strtime+m_xinbox2+m_xinbox1+str2+"考试";
}
else
{
m_xinedit7=comstr2;
}
CString strSQL;
strSQL.Empty();
strSQL="insert into 试卷参数设置(编号,科目,适用对象,难度级别,单选题数量,判断题数量,每单选题分值,每判断题分值,考试时间,外部名,考试印章) values('"+num+"','"+m_xinbox1+"','"
+m_xinbox2+"','"+m_xinbox3+"','"+m_xinedit3+"','"+m_xinedit4+"','"+m_xinedit5+"','"
+m_xinedit6+"','"+m_xinedit1+"','"+m_xinedit7+"','"+strtime+"')";
try
{
pMainFrame->m_database.ExecuteSQL(strSQL);
}
catch(...)
{
AfxMessageBox("出现异常!");
return;
}
CDialog::OnOK();
AfxMessageBox("试卷参数设置成功!");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -