📄 coursesearch.cpp
字号:
// CourseSearch.cpp : implementation file
//
#include "stdafx.h"
#include "SC.h"
#include "Course.h"
#include "CourseSearch.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCourseSearch dialog
CCourseSearch::CCourseSearch(CWnd* pParent /*=NULL*/)
: CDialog(CCourseSearch::IDD, pParent)
{
//{{AFX_DATA_INIT(CCourseSearch)
m_strCredit = _T("");
m_strName = _T("");
m_strNo = _T("");
m_strPno = _T("");
//}}AFX_DATA_INIT
}
void CCourseSearch::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCourseSearch)
DDX_Text(pDX, IDC_SEARCH_CREDIT, m_strCredit);
DDX_Text(pDX, IDC_SEARCH_NAME, m_strName);
DDX_Text(pDX, IDC_SEARCH_NO, m_strNo);
DDX_Text(pDX, IDC_SEARCH_PNO, m_strPno);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCourseSearch, CDialog)
//{{AFX_MSG_MAP(CCourseSearch)
ON_BN_CLICKED(IDC_C_SEARCH, OnCSearch)
ON_EN_CHANGE(IDC_SEARCH_NO, OnChangeSearchNo)
ON_EN_CHANGE(IDC_SEARCH_PNO, OnChangeSearchPno)
ON_EN_CHANGE(IDC_SEARCH_CREDIT, OnChangeSearchCredit)
ON_BN_CLICKED(IDC_C_RESET, OnCReset)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCourseSearch message handlers
void CCourseSearch::OnCSearch()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
CComboBox *SS_NO2=(CComboBox*)GetDlgItem(IDC_SEARCH_NO_2);
CComboBox *SS_PNO2=(CComboBox*)GetDlgItem(IDC_SEARCH_PNO_2);
CComboBox *SS_CREDIT2=(CComboBox*)GetDlgItem(IDC_SEARCH_CREDIT_2);
CString no,pno,credit;
SS_NO2->GetLBText(SS_NO2->GetCurSel(),no);
SS_PNO2->GetLBText(SS_NO2->GetCurSel(),pno);
SS_CREDIT2->GetLBText(SS_CREDIT2->GetCurSel(),credit);
int i=0;
CString str[4];
if(m_strNo.IsEmpty()==1&&m_strName.IsEmpty()==1&&m_strPno.IsEmpty()==1
&&m_strCredit.IsEmpty()==1) return;
m_SQL="SELECT * FROM COURSE WHERE ";
if(m_strNo.IsEmpty()==0)
{
str[i]="Cno"+no+m_strNo;
i++;
}
if(m_strName.IsEmpty()==0)
{
str[i]="Cname='"+m_strName+"'";
i++;
}
if(m_strPno.IsEmpty()==0)
{
str[i]="Cpno"+pno+m_strPno;
i++;
}
if(m_strCredit.IsEmpty()==0)
{
str[i]="Ccredit"+credit+m_strCredit;
i++;
}
for(i=0;i<4;i++)
{
if(i==0)
if(str[i].IsEmpty()==0) m_SQL+=str[i];
if(i!=0)
if(str[i].IsEmpty()==0) m_SQL+=" AND "+str[i];
}
CCourse *pMain=(CCourse*)AfxGetApp()->GetMainWnd();
pMain->m_strSQL=m_SQL;
//pMain=(CStudent *)AfxGetApp()->m_pMainWnd;
//pMain->m_strSQL=m_SQL;
//pMain->UpdateData(TRUE);
MessageBox(pMain->m_strSQL);
this->EndDialog(0);
}
BOOL CCourseSearch::OnInitDialog()
{
CDialog::OnInitDialog();
CComboBox *SS_NO2=(CComboBox*)GetDlgItem(IDC_SEARCH_NO_2);
CComboBox *SS_PNO2=(CComboBox*)GetDlgItem(IDC_SEARCH_PNO_2);
CComboBox *SS_CREDIT2=(CComboBox*)GetDlgItem(IDC_SEARCH_CREDIT_2);
SS_CREDIT2->SetCurSel(0);
SS_NO2->SetCurSel(0);
SS_PNO2->SetCurSel(0);
return TRUE;
}
void CCourseSearch::OnChangeSearchNo()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
CEdit *no=(CEdit*)GetDlgItem(IDC_SEARCH_NO);
UpdateData(TRUE);
CString t_no;
t_no=m_strNo;
if(t_no.IsEmpty()==1) return;
else if(t_no.GetAt(t_no.GetLength()-1)<48||t_no.GetAt(t_no.GetLength()-1)>57)
{
t_no.Delete(t_no.GetLength()-1);
no->SetWindowText(t_no);
}
}
void CCourseSearch::OnChangeSearchPno()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
CEdit *no=(CEdit*)GetDlgItem(IDC_SEARCH_PNO);
UpdateData(TRUE);
CString t_no;
t_no=m_strPno;
if(t_no.IsEmpty()==1) return;
else if(t_no.GetAt(t_no.GetLength()-1)<48||t_no.GetAt(t_no.GetLength()-1)>57)
{
t_no.Delete(t_no.GetLength()-1);
no->SetWindowText(t_no);
}
}
void CCourseSearch::OnChangeSearchCredit()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
CEdit *no=(CEdit*)GetDlgItem(IDC_SEARCH_CREDIT);
UpdateData(TRUE);
CString t_no;
t_no=m_strCredit;
if(t_no.IsEmpty()==1) return;
else if(t_no.GetAt(t_no.GetLength()-1)<48||t_no.GetAt(t_no.GetLength()-1)>57)
{
t_no.Delete(t_no.GetLength()-1);
no->SetWindowText(t_no);
}
}
void CCourseSearch::OnCReset()
{
// TODO: Add your control notification handler code here
CComboBox *SS_NO2=(CComboBox*)GetDlgItem(IDC_SEARCH_NO_2);
CComboBox *SS_PNO2=(CComboBox*)GetDlgItem(IDC_SEARCH_PNO_2);
CComboBox *SS_CREDIT2=(CComboBox*)GetDlgItem(IDC_SEARCH_CREDIT_2);
SS_CREDIT2->SetCurSel(0);
SS_NO2->SetCurSel(0);
SS_PNO2->SetCurSel(0);
CEdit *credit=(CEdit*)GetDlgItem(IDC_SEARCH_CREDIT);
CEdit *no=(CEdit*)GetDlgItem(IDC_SEARCH_NO);
CEdit *pno=(CEdit*)GetDlgItem(IDC_SEARCH_PNO);
CEdit *name=(CEdit*)GetDlgItem(IDC_SEARCH_NAME);
credit->SetWindowText("");
no->SetWindowText("");
pno->SetWindowText("");
name->SetWindowText("");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -