📄 finddlg.cpp
字号:
// FINDDLG.cpp : implementation file
//
#include "stdafx.h"
#include "cyj.h"
#include "FINDDLG.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// FINDDLG dialog
FINDDLG::FINDDLG(CWnd* pParent /*=NULL*/)
: CDialog(FINDDLG::IDD, pParent)
{
//{{AFX_DATA_INIT(FINDDLG)
m_findstr = _T("");
//}}AFX_DATA_INIT
sertflag=false;
m_pSet=new CCyjSet;
}
void FINDDLG::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(FINDDLG)
DDX_Control(pDX, IDC_LIST1, m_list);
DDX_Control(pDX, IDC_COMBO2, m_combo);
DDX_Text(pDX, IDC_FIND, m_findstr);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(FINDDLG, CDialog)
//{{AFX_MSG_MAP(FINDDLG)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// FINDDLG message handlers
BOOL FINDDLG::OnInitDialog()
{
CDialog::OnInitDialog();
m_combo.InsertString(0,"sno");
m_combo.InsertString(1,"sname");
m_combo.InsertString(2,"sage");
m_combo.SetCurSel(0);
if(sertflag)
{
GetDlgItem(IDC_FINDSTR)->ShowWindow(FALSE);
GetDlgItem(IDC_FINDMU)->SetWindowText("排序目标");
GetDlgItem(IDC_FIND)->ShowWindow(FALSE);
GetDlgItem(IDOK)->SetWindowText("排序");}
m_list.SetExtendedStyle(LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT);
m_list.InsertColumn(0,"SNO",LVCFMT_CENTER,80);
m_list.InsertColumn(1,"sname",LVCFMT_CENTER,80);
m_list.InsertColumn(2,"ssex",LVCFMT_CENTER,80);
m_list.InsertColumn(3,"sage",LVCFMT_CENTER,80);
m_list.InsertColumn(4,"sdept",LVCFMT_CENTER,80);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void FINDDLG::OnOK()
{
UpdateData();
int k=m_combo.GetCurSel();
m_combo.GetLBText(k,tempstr);
if(sertflag)
{CString str;
str.Format("%s",tempstr);
m_pSet->m_strSort=str;
strsql="select *from student";
m_pSet->Open(AFX_DB_USE_DEFAULT_TYPE,strsql);
LoadData();}
else
{
strsql.Format("select * from student where %s like '%%%s%%'",tempstr,m_findstr);
m_pSet->Open(AFX_DB_USE_DEFAULT_TYPE,strsql);
LoadData();}
}
void FINDDLG::LoadData()
{m_list.DeleteAllItems();
int i=0;
CString str1;
while(!m_pSet->IsEOF())
{m_pSet->m_sname.TrimRight();
m_pSet->m_ssex.TrimRight();
str1.Format("%d",m_pSet->m_sage);
m_list.InsertItem(i,m_pSet->m_sno);
m_list.SetItemText(i,1,m_pSet->m_sname);
m_list.SetItemText(i,2,m_pSet->m_ssex);
m_list.SetItemText(i,3,str1);
m_list.SetItemText(i,4,m_pSet->m_sdept);
i++;
m_pSet->MoveNext();
}
if(i==0)
MessageBox("数据库中没有此记录!!!");
m_pSet->Requery();
UpdateData(false);
m_pSet->Close();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -