?? borrow.cpp
字號(hào):
// borrow.cpp : implementation file
//
#include "stdafx.h"
#include "圖書館管理系統(tǒng).h"
#include "borrow.h"
#include "client.h"
#include "BookSystem.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// borrow dialog
BookSystem * student;
borrow::borrow(int i, CWnd* pParent /*=NULL*/)
: CDialog(borrow::IDD, pParent),booksystem(i)
{
//{{AFX_DATA_INIT(borrow)
m_bookname = _T("");
m_author = _T("");
m_booktype = _T("");
//}}AFX_DATA_INIT
}
void borrow::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(borrow)
DDX_Control(pDX, IDC_BOOKLIST, m_booklist);
DDX_Control(pDX, IDC_BOOKWR, m_bauthor);
DDX_Control(pDX, IDC_BOOKNAME, m_bname);
DDX_Control(pDX, IDC_COMBO_PUBLISH, m_press);
DDX_Text(pDX, IDC_BOOKNAME, m_bookname);
DDX_Text(pDX, IDC_BOOKWR, m_author);
DDX_Text(pDX, IDC_BOOKTYPE, m_booktype);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(borrow, CDialog)
//{{AFX_MSG_MAP(borrow)
ON_BN_CLICKED(IDD_ABOUTBOX12, OnSEARCH)
ON_BN_CLICKED(IDD_ABOUTBOX11, OnBORROW)
ON_BN_CLICKED(IDD_ABOUTBOX13, OnAboutbox13)
ON_EN_CHANGE(IDC_BOOKTYPE, OnChangeBooktype)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// borrow message handlers
void borrow::OnSEARCH() //查找功能
{
// TODO: Add your control notification handler code here
UpdateData(1);
int pressnum = m_press.GetCurSel();
if (m_booktype=="")
{
if (m_bookname=="" && m_author==""&&pressnum==-1 ) MessageBox("請(qǐng)輸入你要查找的書!","注意");
else if (m_author==""&&pressnum==-1)
{
student->Print_Bookname(m_bookname,student,m_booklist);
}
else if (m_bookname==""&&pressnum==-1) {student->Print_Author(m_author,student,m_booklist);
}
else if (m_bookname==""&&m_author=="") {m_press.GetLBText(pressnum,m_publish);
student->Print_Press(m_publish,student,m_booklist);
}
else if (pressnum==-1) {student->Print_BandA(m_bookname,m_author,student,m_booklist);
}
else if (m_bookname=="") {m_press.GetLBText(pressnum,m_publish);student->Print_PandA(m_publish,m_author,student,m_booklist);
}
else if (m_author=="") {m_press.GetLBText(pressnum,m_publish);student->Print_PandB(m_publish,m_bookname,student,m_booklist);
}
else {m_press.GetLBText(pressnum,m_publish);student->Print_PandBandA(m_publish,m_bookname,m_author,student,m_booklist);
}
}
else student->Print_Type(m_booktype,student,m_booklist);
m_bookname = '\0';
m_author = '\0';
// m_booktype = '\0';
m_press.SetCurSel(-1);
UpdateData(0);
}
void borrow::OnBORROW()
{
// TODO: Add your control notification handler code here
CFile write;
if (!write.Open(m_path,CFile::modeReadWrite|CFile::modeCreate|CFile::modeNoTruncate))
{
MessageBox ("Openning file error!");
return;
}
else MessageBox ("Success!");
int listnum = m_booklist.GetCurSel();
m_booklist.GetText(listnum,list);
list += '&';
MessageBox(list);
write.SeekToEnd();
write.Write(list,list.GetLength());
write.Close();
}
void borrow::OnAboutbox13()
{
// TODO: Add your control notification handler code here
CDialog::OnCancel();
}
//////////////////////////////////////////////////////////////初始化函數(shù)
BOOL borrow::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
if (booksystem) m_bookname="",m_author="",m_press.ResetContent();
CFile Read_BookStore;
student=new BookSystem;
CString temp_bookname;
CString temp_author;
CString temp_press;
CString temp_type;
CString temp_number;
int create = 0; //數(shù)據(jù)文件建立標(biāo)志;
int flag1 = 1;
int flag3 = 1;
int flag4 = 1;
int flag5 = 1;
///////////////////////////////////////////////////////////建立連表
if(booksystem)
{
if(Read_BookStore.Open("BookStore\\BookStore.txt",CFile::modeRead))
{ create = 1;
char temp[1];
while(Read_BookStore.Read(temp,1))//while
{
while(temp[0]!='~'&&temp[0]!='\n')//讀取一個(gè)文本對(duì)象信息;
{
if(flag1){while(temp[0]!='#'){temp_bookname+=temp[0];Read_BookStore.Read(temp,1);}flag1 = 0;}
else{
if(flag2){Read_BookStore.Read(temp,1);while(temp[0]!='#'){temp_author+=temp[0];Read_BookStore.Read(temp,1);}flag2 = 0;}
else{
if(flag3){Read_BookStore.Read(temp,1);while(temp[0]!='#'){temp_press+=temp[0];Read_BookStore.Read(temp,1);}flag3 = 0;}
else{
if(flag4){Read_BookStore.Read(temp,1);while(temp[0]!='#'){temp_type+=temp[0];Read_BookStore.Read(temp,1);}flag4 = 0;}
else{
if(flag5){Read_BookStore.Read(temp,1);while(temp[0]!='~'){temp_number+=temp[0];Read_BookStore.Read(temp,1);}flag5 = 0;}}}}}
}
////////////////******************
// MessageBox(temp_bookname+" "+temp_author+" "+temp_press+" "+temp_type+" "+temp_number); //讀出檢驗(yàn)
student->InsertBookSystem(temp_press,temp_bookname,temp_author,temp_type,student);//鏈表建立
flag1 = 1;temp_bookname.Empty();//數(shù)據(jù)回原;
flag2 = 1;temp_type.Empty();
flag3 = 1;temp_author.Empty();
flag4 = 1;temp_press.Empty();
flag5 = 1;temp_number.Empty();
}//end while;
Read_BookStore.Close();//關(guān)閉文件;
}//讀取信息文件;
else{
if(Read_BookStore.Open("BookStore\\BookStore.txt",CFile::modeCreate))
create = 1;
Read_BookStore.Close();//關(guān)閉文件;
}//bookname創(chuàng)建信息文Type件;
booksystem = 0;
}
////////////////////////////
if (create) {}
else MessageBox("系統(tǒng)出現(xiàn)問(wèn)題!","警告");
booksystem = 0;
////////////////////讀入出版社資料
CFile file;
CString pb;
char t[1];
file.Open("Publish.txt",CFile::modeRead);
///////////////////////讀文檔
while (file.Read(t,1))
{
if(t[0] == '&')
{
type=pb;
m_press.AddString(type);
pb = "";
continue;
}
pb+=t[0];
}
UpdateData(1);
file.Close();
///////////////////////讀入完畢
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void borrow::OnChangeBooktype()
{
// 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
UpdateData(1);
if (m_booktype!="")
{ m_bname.EnableWindow(0);
m_bauthor.EnableWindow(0);
m_press.EnableWindow(0);
}
else
{
m_bname.EnableWindow(1);
m_bauthor.EnableWindow(1);
m_press.EnableWindow(1);
}
UpdateData(0);
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -