📄 dlgquery.cpp
字号:
// DLGquery.cpp : implementation file
//
#include "stdafx.h"
#include "STUGRADE.h"
#include "DLGquery.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDLGquery dialog
CDLGquery::CDLGquery(CWnd* pParent /*=NULL*/)
: CDialog(CDLGquery::IDD, pParent)
{
//{{AFX_DATA_INIT(CDLGquery)
//}}AFX_DATA_INIT
}
void CDLGquery::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDLGquery)
DDX_Control(pDX, IDC_CHECK1, m_CHECK);
DDX_Control(pDX, IDC_EDIT4, m_EDIT_then4);
DDX_Control(pDX, IDC_EDIT3, m_EDIT_then3);
DDX_Control(pDX, IDC_EDIT2, m_EDIT_then2);
DDX_Control(pDX, IDC_COMBO4, m_CBO_IF4);
DDX_Control(pDX, IDC_COMBO3, m_CBO_IF3);
DDX_Control(pDX, IDC_COMBO2, m_CBO_IF2);
DDX_Control(pDX, IDC_EDIT1, m_EDIT_then1);
DDX_Control(pDX, IDC_COMBO1, m_CBO_IF1);
DDX_Control(pDX, IDC_COMBO_andor4, m_CBO_andor4);
DDX_Control(pDX, IDC_COMBO_andor3, m_CBO_andor3);
DDX_Control(pDX, IDC_COMBO_andor2, m_CBO_andor2);
DDX_Control(pDX, IDC_COMBO_andor1, m_CBO_andor1);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDLGquery, CDialog)
//{{AFX_MSG_MAP(CDLGquery)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDLGquery message handlers
BOOL CDLGquery::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
this->m_CBO_andor1.EnableWindow(FALSE);
this->m_CBO_andor1.SetCurSel(0);
this->m_CBO_andor2.SetCurSel(0);
this->m_CBO_andor3.SetCurSel(0);
this->m_CBO_andor4.SetCurSel(0);
this->m_CBO_IF1.SetCurSel(0);
this->m_CBO_IF2.SetCurSel(0);
this->m_CBO_IF3.SetCurSel(0);
this->m_CBO_IF4.SetCurSel(0);
this->m_CHECK.SetCheck(true);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDLGquery::OnOK()
{
CString szSQL,szSQLlast,sql1,sql2,sql3,sql4;
CString Ctext1,Ctext2,Ctext3,Ctext4,text1,text2,text3,text4,AR2,AR3,AR4;
szSQL="SELECT 班级名称,学生基本信息.学号,姓名,课程名称,考试名称,成绩,专业名称,系名 FROM 成绩表,学生基本信息,考试类型代码,班级信息,课程信息,专业信息,系别信息 WHERE 系别信息.系别代码 = 专业信息.所属系别 AND 专业信息.专业代码 = 班级信息.所属专业 AND 成绩表.学号 = 学生基本信息.学号 AND 成绩表.考试代码 = 考试类型代码.考试代码 AND 学生基本信息.所属班级 = 班级信息.班级代码 AND 成绩表.课程代码 = 课程信息.课程代码 ";
m_CBO_andor2.GetWindowText(AR2);
m_CBO_andor3.GetWindowText(AR3);
m_CBO_andor4.GetWindowText(AR4);
m_CBO_IF1.GetWindowText(Ctext1);
m_CBO_IF2.GetWindowText(Ctext2);
m_CBO_IF3.GetWindowText(Ctext3);
m_CBO_IF4.GetWindowText(Ctext4);
if (Ctext1=="学号") Ctext1="学生基本信息.学号";
if (Ctext2=="学号") Ctext2="学生基本信息.学号";
if (Ctext3=="学号") Ctext3="学生基本信息.学号";
if (Ctext4=="学号") Ctext4="学生基本信息.学号";
m_EDIT_then1.GetWindowText(text1);
m_EDIT_then2.GetWindowText(text2);
m_EDIT_then3.GetWindowText(text3);
m_EDIT_then4.GetWindowText(text4);
if (m_CHECK.GetCheck())
{
if ((Ctext1!="请选择...") && (!text1.IsEmpty()))
{
sql1.Format(" %s like '",Ctext1);
sql1+="%";
sql1+=text1;
sql1+="%'";
}
if ((Ctext2!="请选择...") && (!text2.IsEmpty()))
{
sql2.Format(" %s %s like '",AR2,Ctext2);
sql2+="%";
sql2+=text2;
sql2+="%'";
}
if ((Ctext3!="请选择...") && (!text3.IsEmpty()))
{
sql3.Format(" %s %s like '",AR3,Ctext3);
sql3+="%";
sql3+=text3;
sql3+="%'";
}
if ((Ctext4!="请选择...") && (!text4.IsEmpty()))
{
sql4.Format(" %s %s like '",AR4,Ctext4);
sql4+="%";
sql4+=text4;
sql4+="%'";
}
}
else
{
if ((Ctext1!="请选择...") && (!text1.IsEmpty()))
sql1.Format(" %s = '%s'",Ctext1,text1);
if ((Ctext2!="请选择...") && (!text2.IsEmpty()))
sql2.Format(" %s %s = '%s'",AR2,Ctext2,text2);
if ((Ctext3!="请选择...") && (!text3.IsEmpty()))
sql3.Format(" %s %s = '%s'",AR3,Ctext3,text3);
if ((Ctext4!="请选择...") && (!text4.IsEmpty()))
sql4.Format(" %s %s = '%s'",AR4,Ctext4,text4);
}
szSQLlast.Format("AND (%s%s%s%s)",sql1,sql2,sql3,sql4);
if (sql1.IsEmpty() && ( sql2.IsEmpty() || sql3.IsEmpty() || sql4.IsEmpty())) //把多出来的AND OR删除
{
int fc=szSQLlast.Find("AND",4);
if (fc!=-1) //删除AND
szSQLlast.Delete(fc,3);
else
{
fc=szSQLlast.Find("OR",4);
szSQLlast.Delete(fc,2);
}
}
if (sql1.IsEmpty() && sql2.IsEmpty() && sql3.IsEmpty() && sql4.IsEmpty())
szSQLlast.Empty();
szSQL+=szSQLlast;
// AfxMessageBox(szSQL); //太长了,调试窗口显示不完整
strcpy(szSQLt,(LPSTR)(LPCSTR)szSQL);
CDialog::OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -