📄 student_book_search.cpp
字号:
// Student_book_search.cpp : implementation file
//
#include "stdafx.h"
#include "Library.h"
#include "Student_book_search.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// Student_book_search dialog
Student_book_search::Student_book_search(CWnd* pParent /*=NULL*/)
: CDialog(Student_book_search::IDD, pParent)
{
//{{AFX_DATA_INIT(Student_book_search)
m_bname_temp = _T("");
m_bauthor_temp = _T("");
//}}AFX_DATA_INIT
}
void Student_book_search::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(Student_book_search)
DDX_Control(pDX, IDC_LIST2, m_total_list);
DDX_Control(pDX, IDC_LIST1, m_book_list);
DDX_Text(pDX, IDC_EDIT1, m_bname_temp);
DDX_Text(pDX, IDC_EDIT2, m_bauthor_temp);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(Student_book_search, CDialog)
//{{AFX_MSG_MAP(Student_book_search)
ON_BN_CLICKED(IDOK3, OnOk3)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Student_book_search message handlers
void Student_book_search::OnOK()// 按书名检索
{
// TODO: Add extra validation here
UpdateData(TRUE);
m_book_list.ResetContent();//列表清空
m_total_list.ResetContent();
int i=0;
if(m_bname_temp.IsEmpty())
{
MessageBox("请输入书名!");
return;
}
//查找
CString str="Bname='"+m_bname_temp+"'";
book_set.m_strFilter=str;
book_set.Open(); //打开数据集合
int recount=book_set.GetRecordCount();
if(recount==0)
{
MessageBox("无此图书记录!");
book_set.m_strFilter="";
return;
}
else
{
while(!book_set.IsEOF()) //判断是否为结尾
{
if(book_set.m_Bname==m_bname_temp)
{
CString temp;
temp.Format("No.%d ISBN:%s 书名:%s 作者:%s 出版社:%s 现库存:%d",
i,book_set.m_ISBN,book_set.m_Bname,book_set.m_Bauthor,
book_set.m_Bpublisher,book_set.m_B_left_count);
i++;
m_book_list.InsertString(-1,temp);
}
book_set.MoveNext();
}
}
CString total;
total.Format("%d",i);
m_total_list.InsertString(-1,total);
UpdateData(FALSE);//显示
book_set.MoveFirst();
book_set.Requery();
book_set.Close();
}
void Student_book_search::OnOk3()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_book_list.ResetContent();//列表清空
m_total_list.ResetContent();
int i=0;
if(m_bauthor_temp.IsEmpty())
{
MessageBox("请输入作者名!");
return;
}
//查找
CString str="Bauthor='"+m_bauthor_temp+"'";
book_set.m_strFilter=str;
book_set.Open(); //打开数据集合
int recount=book_set.GetRecordCount();
if(recount==0)
{
MessageBox("无此图书记录!");
book_set.m_strFilter="";
return;
}
else
{
while(!book_set.IsEOF()) //判断是否为结尾
{
if(book_set.m_Bauthor==m_bauthor_temp)
{
CString temp;
temp.Format("No.%d ISBN:%s 书名:%s 作者:%s 出版社:%s 现库存:%d",
i,book_set.m_ISBN,book_set.m_Bname,book_set.m_Bauthor,
book_set.m_Bpublisher,book_set.m_B_left_count);
m_book_list.InsertString(-1,temp);
i++;
}
book_set.MoveNext();
}
}
CString total;
total.Format("%d",i);
m_total_list.InsertString(-1,total);
UpdateData(FALSE);//显示
book_set.MoveFirst();
book_set.Requery();
book_set.Close();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -