⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 seedialog.cpp

📁 这是目前正应用于辽宁省很多县级中学的试题库系统源代码
💻 CPP
字号:
// SeeDialog.cpp : implementation file
//

#include "stdafx.h"
#include "TestPaper.h"
#include "SeeDialog.h"
#include "MainFrm.h"
#include "ScoreDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CSeeDialog dialog

CString title;

CSeeDialog::CSeeDialog(CWnd* pParent /*=NULL*/)
	: CDialog(CSeeDialog::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSeeDialog)
	m_strbox1 = _T("");
	m_strbox2 = _T("");
	m_edit1 = _T("");
	m_strbox3 = _T("");
	//}}AFX_DATA_INIT
}


void CSeeDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSeeDialog)
	DDX_Control(pDX, IDC_COMBO4, m_seebox3);
	DDX_Control(pDX, IDC_COMBO3, m_seebox2);
	DDX_Control(pDX, IDC_COMBO1, m_seebox1);
	DDX_CBString(pDX, IDC_COMBO1, m_strbox1);
	DDX_CBString(pDX, IDC_COMBO3, m_strbox2);
	DDX_Text(pDX, IDC_EDIT1, m_edit1);
	DDX_CBString(pDX, IDC_COMBO4, m_strbox3);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSeeDialog, CDialog)
	//{{AFX_MSG_MAP(CSeeDialog)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSeeDialog message handlers

BOOL CSeeDialog::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	
	CMainFrame* pMainFrame=(CMainFrame*) AfxGetMainWnd();
	CString pan;
	CString duan;
	CDBVariant OleVar;
	HICON hIcon=AfxGetApp()->LoadIcon(IDI_ICON12);
	this->SendMessage(WM_SETICON,ICON_BIG,(LPARAM)hIcon);
	pMainFrame->m_seerecordset.MoveFirst();
	pan="";
    duan =""; 
	while(!pMainFrame->m_seerecordset.IsEOF())
	{
		pMainFrame->m_seerecordset.GetFieldValue(3,OleVar);
		pan =OleVar.m_pstring->GetBuffer(1);
		if(pan.Compare(duan)!=0)
		{
			int wcount=m_seebox1.GetCount();
			CString rString;
			BOOL dao=TRUE;
			for(int jj=0;jj<wcount;jj++)
			{
				m_seebox1.GetLBText(jj,rString);
				if(rString.Compare(pan)==0)
				{
					dao=FALSE;
				}
			}
			if(dao==TRUE)
			{
				m_seebox1.AddString(pan);
			}
			
		} 
		duan=pan;
        pMainFrame->m_seerecordset.MoveNext();
	}
	//m_seebox1.SetCurSel(0);



	CString pa;
	CString dua;
	CDBVariant OleVar2;
	pMainFrame->m_seerecordset.MoveFirst();
	pa="";
    dua =""; 
	while(!pMainFrame->m_seerecordset.IsEOF())
	{
		pMainFrame->m_seerecordset.GetFieldValue(5,OleVar2);
		pa =OleVar2.m_pstring->GetBuffer(1);
		if(pa.Compare(dua)!=0)
		{
			int count=m_seebox2.GetCount();
			CString rStrin;
			BOOL da=TRUE;
			for(int jjj=0;jjj<count;jjj++)
			{
				m_seebox2.GetLBText(jjj,rStrin);
				if(rStrin.Compare(pa)==0)
				{
					da=FALSE;
				}
			}
			if(da==TRUE)
			{
				m_seebox2.AddString(pa);
			}
			
		} 
		dua=pa;
        pMainFrame->m_seerecordset.MoveNext();
	}
	//m_seebox2.SetCurSel(0);
	CStdioFile MyFile;
	CString str;
	MyFile.Open("外部接口\\题库管理之学科名称.txt",CFile::modeRead|CFile::typeText);
	MyFile.SeekToBegin();
	while(MyFile.ReadString(str))
	{
		if(str!="")
		{
		m_seebox3.AddString(str); 
		str.Empty();
		}
	}
	MyFile.Close();
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CSeeDialog::OnButton1() 
{
	// TODO: Add your control notification handler code here
	CMainFrame* pMainFrame=(CMainFrame*) AfxGetMainWnd();
	UpdateData(TRUE);
	if(m_strbox1=="" && m_strbox2=="" && m_strbox3=="" && m_edit1=="")
	{
		AfxMessageBox("请输入查询条件!");
		return;
	}
	if(m_strbox1!="" && m_strbox2!="" && m_edit1!="" && m_strbox3!="")
	{
		title="select * from 成绩 where 考试时间='"+m_strbox1+"' and 队别='"+m_strbox2+"' and 学生姓名='"+m_edit1+"' and 考试科目='"+m_strbox3+"'";
	}
	if(m_strbox1!="" && m_strbox2!="" && m_strbox3!="" && m_edit1=="")
	{
	    title="select * from 成绩 where 考试时间='"+m_strbox1+"' and 队别='"+m_strbox2+"' and 考试科目='"+m_strbox3+"'";
	}
	if(m_strbox1!="" && m_strbox2!="" && m_strbox3=="" && m_edit1!="")
	{
	    title="select * from 成绩 where 考试时间='"+m_strbox1+"' and 队别='"+m_strbox2+"' and 学生姓名='"+m_edit1+"'";
	}
	if(m_strbox1!="" && m_strbox2!="" && m_edit1=="" && m_strbox3=="")
	{
		title="select * from 成绩 where 考试时间='"+m_strbox1+"' and 队别='"+m_strbox2+"'";
	}

	if(m_strbox1!="" && m_strbox2=="" && m_edit1!="" && m_strbox3!="")
	{
		title="select * from 成绩 where 考试时间='"+m_strbox1+"' and 学生姓名='"+m_edit1+"' and 考试科目='"+m_strbox3+"'";
	}
	if(m_strbox1!="" && m_strbox2=="" && m_strbox3!="" && m_edit1=="")
	{
	    title="select * from 成绩 where 考试时间='"+m_strbox1+"' and 考试科目='"+m_strbox3+"'";
	}
	if(m_strbox1!="" && m_strbox2=="" && m_strbox3=="" && m_edit1!="")
	{
	    title="select * from 成绩 where 考试时间='"+m_strbox1+"' and 学生姓名='"+m_edit1+"'";
	}
	if(m_strbox1!="" && m_strbox2=="" && m_edit1=="" && m_strbox3=="")
	{
		title="select * from 成绩 where 考试时间='"+m_strbox1+"'";
	}



	if(m_strbox1=="" && m_strbox2!="" && m_edit1!="" && m_strbox3!="")
	{
		title="select * from 成绩 where 队别='"+m_strbox2+"' and 学生姓名='"+m_edit1+"' and 考试科目='"+m_strbox3+"'";
	}
	if(m_strbox1=="" && m_strbox2!="" && m_strbox3!="" && m_edit1=="")
	{
	    title="select * from 成绩 where 队别='"+m_strbox2+"' and 考试科目='"+m_strbox3+"'";
	}
	if(m_strbox1=="" && m_strbox2!="" && m_strbox3=="" && m_edit1!="")
	{
	    title="select * from 成绩 where 队别='"+m_strbox2+"' and 学生姓名='"+m_edit1+"'";
	}
	if(m_strbox1=="" && m_strbox2!="" && m_edit1=="" && m_strbox3=="")
	{
		title="select * from 成绩 where 队别='"+m_strbox2+"'";
	}

	if(m_strbox1=="" && m_strbox2=="" && m_edit1!="" && m_strbox3!="")
	{
		title="select * from 成绩 where 学生姓名='"+m_edit1+"' and 考试科目='"+m_strbox3+"'";
	}
	if(m_strbox1=="" && m_strbox2=="" && m_strbox3!="" && m_edit1=="")
	{
	    title="select * from 成绩 where 考试科目='"+m_strbox3+"'";
	}
	if(m_strbox1=="" && m_strbox2=="" && m_strbox3=="" && m_edit1!="")
	{
	    title="select * from 成绩 where 学生姓名='"+m_edit1+"'";
	}
	try
	{
		if(pMainFrame->m_xinpaperset.IsOpen())
		{
			pMainFrame->m_xinpaperset.Close();
            pMainFrame->m_xinpaperset.Open(CRecordset::dynaset,title);
		}
		else
		{
			pMainFrame->m_xinpaperset.Open(CRecordset::dynaset,title);
		}
	}
	catch(...)
	{
		AfxMessageBox("cann't open table!");
		return;
	}
	
	if(pMainFrame->m_xinpaperset.GetRecordCount()==0)
	{
		AfxMessageBox("无记录!");
		return;
	}
    CScoreDialog scoredlg;
	scoredlg.DoModal();
}

void CSeeDialog::OnButton2() 
{
	// TODO: Add your control notification handler code here
	CDialog::OnOK();
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -