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

📄 xinquerydialog.cpp

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

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

/////////////////////////////////////////////////////////////////////////////
// CXinQueryDialog dialog


CXinQueryDialog::CXinQueryDialog(CWnd* pParent /*=NULL*/)
	: CDialog(CXinQueryDialog::IDD, pParent)
{
	//{{AFX_DATA_INIT(CXinQueryDialog)
	m_queryedit1 = _T("");
	m_query7 = _T("");
	m_query6 = _T("");
	m_query5 = _T("");
	m_query1 = _T("");
	//}}AFX_DATA_INIT
}


void CXinQueryDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CXinQueryDialog)
	DDX_Control(pDX, IDC_COMBO6, m_conQuery6);
	DDX_Control(pDX, IDC_CHECK5, m_check5);
	DDX_Control(pDX, IDC_CHECK4, m_check4);
	DDX_Control(pDX, IDC_CHECK3, m_check3);
	DDX_Control(pDX, IDC_CHECK2, m_check2);
	DDX_Control(pDX, IDC_CHECK1, m_check1);
	DDX_Control(pDX, IDC_COMBO1, m_conQuery1);
	DDX_Text(pDX, IDC_EDIT1, m_queryedit1);
	DDX_CBString(pDX, IDC_COMBO7, m_query7);
	DDX_CBString(pDX, IDC_COMBO6, m_query6);
	DDX_CBString(pDX, IDC_COMBO5, m_query5);
	DDX_CBString(pDX, IDC_COMBO1, m_query1);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CXinQueryDialog, CDialog)
	//{{AFX_MSG_MAP(CXinQueryDialog)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
	ON_BN_CLICKED(IDC_CHECK1, OnCheck1)
	ON_BN_CLICKED(IDC_CHECK2, OnCheck2)
	ON_BN_CLICKED(IDC_CHECK3, OnCheck3)
	ON_BN_CLICKED(IDC_CHECK4, OnCheck4)
	ON_BN_CLICKED(IDC_CHECK5, OnCheck5)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CXinQueryDialog message handlers

BOOL CXinQueryDialog::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	HICON hIcon=AfxGetApp()->LoadIcon(IDI_ICON14);
	this->SendMessage(WM_SETICON,ICON_BIG,(LPARAM)hIcon);
	GetDlgItem(IDC_EDIT1)->EnableWindow(false);
	GetDlgItem(IDC_COMBO5)->EnableWindow(false);
	GetDlgItem(IDC_COMBO1)->EnableWindow(false);
	GetDlgItem(IDC_COMBO6)->EnableWindow(false);
	GetDlgItem(IDC_COMBO7)->EnableWindow(false);
	checkbool1=FALSE;
	checkbool2=FALSE;
	checkbool3=FALSE;
	checkbool4=FALSE;
	checkbool5=FALSE;


	CStdioFile MyFile;
	CString str;
	
	MyFile.Open("外部接口\\题库管理之学科名称.txt",CFile::modeRead|CFile::typeText);
	MyFile.SeekToBegin();
	while(MyFile.ReadString(str))
	{
		if(str!="")
		{
		m_conQuery1.AddString(str); 
		str.Empty();
		}
	}
	MyFile.Close();
	str.Empty();

	MyFile.Open("外部接口\\题库管理之考试对象.txt",CFile::modeRead|CFile::typeText);
	MyFile.SeekToBegin();
	while(MyFile.ReadString(str))
	{
		if(str!="")
		{
		m_conQuery6.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 CXinQueryDialog::OnButton1() //查询函数
{
	// TODO: Add your control notification handler code here

	CMainFrame* pMainFrame=(CMainFrame*) AfxGetMainWnd();

	UpdateData(TRUE);
	pMainFrame->tempyang1=m_query1;
	pMainFrame->tempyang2=m_query5;
	CString strSQL;
	strSQL.Empty();
    if(m_check1.GetCheck()==1 && m_query1!="")
	{
		checkbool1=TRUE;
	}
	else
	{
		checkbool1=FALSE;
	}
	if(m_check2.GetCheck()==1 && m_query5!="")
	{
		checkbool2=TRUE;
	}
	else
	{
		checkbool2=FALSE;
	}
   
	if(m_check3.GetCheck()==1 && m_queryedit1!="")
	{
		checkbool3=TRUE;
	}
	else
	{
		checkbool3=FALSE;
	}
	if(m_check4.GetCheck()==1 && m_query6!="")
	{
		checkbool4=TRUE;
	}
	else
	{
		checkbool4=FALSE;
	}
	if(m_check5.GetCheck()==1 && m_query7!="")
	{
		checkbool5=TRUE;
	}
	else
	{
		checkbool5=FALSE;
	}
	if(checkbool1==FALSE)
	{
		AfxMessageBox("请输入科目类型!");
		return;
	}
	if(checkbool2==FALSE)
	{
		AfxMessageBox("请输入试题类型!");
		return;
	}
	
	if(checkbool3==FALSE && checkbool4==FALSE && checkbool5==FALSE)
	{
		AfxMessageBox("请输入查询条件!");
		return;
	}
	if(checkbool3)
	{
	   strSQL.Format("select * from %s%s where 题目编号="+m_queryedit1+"",m_query1,m_query5);
	}
	else
	{
		   
			   if(checkbool4==TRUE && checkbool5==FALSE)
			   {
			   strSQL.Format("select * from %s%s where 考试对象='"+m_query6+"'",m_query1,m_query5);
			   }
		       if(checkbool4==TRUE && checkbool5==TRUE)
			   {
			   strSQL.Format("select * from %s%s where 考试对象='"+m_query6+"' and 难度级别="+m_query7+"",m_query1,m_query5);
			   }
		       if(checkbool4==FALSE && checkbool5==TRUE)
			   {
			   strSQL.Format("select * from %s%s where 难度级别="+m_query7+"",m_query1,m_query5);
			   }
		   
	}
	try
	{
		if(pMainFrame->m_queryset.IsOpen())
		{
			pMainFrame->m_queryset.Close();
            pMainFrame->m_queryset.Open(CRecordset::dynaset,strSQL);
		}
		else
		{
			pMainFrame->m_queryset.Open(CRecordset::dynaset,strSQL);
		}
	}
	catch(...)
	{
		AfxMessageBox("cann't open table!");
		return;
	}
	if(pMainFrame->m_queryset.GetRecordCount()==0)
	{
		AfxMessageBox("对不起,无查询结果!");
		return;
	}
	CDialog::OnOK();
	//this->ShowWindow(SW_HIDE);

	
	pMainFrame->redlg.DoModal();

	
}

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

void CXinQueryDialog::OnCheck1() 
{
	// TODO: Add your control notification handler code here
	if(m_check1.GetCheck()==1)
		GetDlgItem(IDC_COMBO1)->EnableWindow(true);
	if(m_check1.GetCheck()==0)
		GetDlgItem(IDC_COMBO1)->EnableWindow(false);
	
}

void CXinQueryDialog::OnCheck2() 
{
	// TODO: Add your control notification handler code here
	if(m_check2.GetCheck()==1)
		GetDlgItem(IDC_COMBO5)->EnableWindow(true);
	if(m_check2.GetCheck()==0)
		GetDlgItem(IDC_COMBO5)->EnableWindow(false);
	
}

void CXinQueryDialog::OnCheck3() 
{
	// TODO: Add your control notification handler code here
	if(m_check3.GetCheck()==1)
		GetDlgItem(IDC_EDIT1)->EnableWindow(true);
	if(m_check3.GetCheck()==0)
		GetDlgItem(IDC_EDIT1)->EnableWindow(false);
	
}

void CXinQueryDialog::OnCheck4() 
{
	// TODO: Add your control notification handler code here
	if(m_check4.GetCheck()==1)
		GetDlgItem(IDC_COMBO6)->EnableWindow(true);
	if(m_check4.GetCheck()==0)
		GetDlgItem(IDC_COMBO6)->EnableWindow(false);
	
}

void CXinQueryDialog::OnCheck5() 
{
	// TODO: Add your control notification handler code here
	if(m_check5.GetCheck()==1)
		GetDlgItem(IDC_COMBO7)->EnableWindow(true);
	if(m_check5.GetCheck()==0)
		GetDlgItem(IDC_COMBO7)->EnableWindow(false);
	
}

⌨️ 快捷键说明

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