📄 dialogquery.cpp
字号:
// DialogQuery.cpp : implementation file
//
#include "stdafx.h"
#include "Student.h"
#include "DialogQuery.h"
#include "AdoDb.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDialogQuery dialog
CDialogQuery::CDialogQuery(CWnd* pParent /*=NULL*/)
: CDialog(CDialogQuery::IDD, pParent)
{
//{{AFX_DATA_INIT(CDialogQuery)
//}}AFX_DATA_INIT
}
void CDialogQuery::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDialogQuery)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDialogQuery, CDialog)
//{{AFX_MSG_MAP(CDialogQuery)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDialogQuery message handlers
void CDialogQuery::OnOK()
{
// TODO: Add extra validation here
UpdateData(TRUE);
CString strqueryNum,strqueryName;
GetDlgItemText(IDC_EDIT_QUERYNUM,strqueryNum);
GetDlgItemText(IDC_EDIT_QUERYNAME,strqueryName);
SetDlgItemText(IDC_EDIT_QUERYNUM,_T(""));
SetDlgItemText(IDC_EDIT_QUERYNAME,_T(""));
if (strqueryNum.GetLength()==0&&strqueryName.GetLength()==0)
{
MessageBox("请注意添加所需的查询条件!");
return;
}
//构造SQL语句
CString sqlquery;
if(strqueryNum.GetLength()>0&&strqueryName.GetLength()>0)
{
sqlquery.Format("select * from student where STU_NUM='%s' and STU_NAME='%s'",strqueryNum,strqueryName);
}
if (strqueryNum.GetLength()>0&&strqueryName.GetLength()==0)
{
sqlquery.Format("select * from student where STU_NUM='%s'",strqueryNum);
}
if (strqueryNum.GetLength()==0&&strqueryName.GetLength()>0)
{
sqlquery.Format("select * from student where STU_NAME='%s'",strqueryName);
}
//执行SQL语句
theApp.m_ado.ExeQureSql(sqlquery);
CDialog::OnOK();
}
void CDialogQuery::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
// CDialogQuery::OnCancel();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -