📄 book_search.cpp
字号:
// Book_search.cpp : implementation file
//
#include "stdafx.h"
#include "Library.h"
#include "Book_search.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// Book_search dialog
Book_search::Book_search(CWnd* pParent /*=NULL*/)
: CDialog(Book_search::IDD, pParent)
{
//{{AFX_DATA_INIT(Book_search)
m_isbn_temp = _T("");
m_bname_temp = _T("");
//}}AFX_DATA_INIT
}
void Book_search::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(Book_search)
DDX_Control(pDX, IDC_LIST4, m_total_list);
DDX_Control(pDX, IDC_LIST1, m_book_list);
DDX_Text(pDX, IDC_EDIT2, m_isbn_temp);
DDX_Text(pDX, IDC_EDIT1, m_bname_temp);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(Book_search, CDialog)
//{{AFX_MSG_MAP(Book_search)
ON_BN_CLICKED(IDOK2, OnOk2)
ON_BN_CLICKED(IDOK1, OnOk1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Book_search message handlers
void Book_search::OnOk1()
{
// TODO: Add your control notification handler code 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="";
}
else
{
while(!book_set.IsEOF()) //判断是否为结尾
{
if(book_set.m_Bname==m_bname_temp)
{
CString temp;
temp.Format("No.%d ISBN:%s书名:%s 作者:%s 译者:%s 出版社:%s 定价:%f 总库存:%d 现库存:%d",
i+1,book_set.m_ISBN,book_set.m_Bname,book_set.m_Bauthor,
book_set.m_Btran,book_set.m_Bpublisher,book_set.m_Bprice,book_set.m_B_total_count,
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 Book_search::OnOk2()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_book_list.ResetContent();//列表清空
m_total_list.ResetContent();
int i=1;
if(m_isbn_temp.IsEmpty())
{
MessageBox("请输入书号!");
return;
}
//查找
CString str="ISBN='"+m_isbn_temp+"'";
book_set.m_strFilter=str;
book_set.Open(); //打开数据集合
int recount=book_set.GetRecordCount();
if(recount==0)
{
MessageBox("无此图书记录!");
book_set.m_strFilter="";
}
else
{
CString temp;
temp.Format("No.%d ISBN:%s\n书名:%s 作者:%s 译者:%s 出版社:%s 定价:%f 总库存:%d 现库存:%d",
i,book_set.m_ISBN,book_set.m_Bname,book_set.m_Bauthor,
book_set.m_Btran,book_set.m_Bpublisher,book_set.m_Bprice,book_set.m_B_total_count,
book_set.m_B_left_count);
m_book_list.InsertString(-1,temp);
}
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 + -