⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 returnbook.cpp

📁 基于MFC实现的图书管管理系统
💻 CPP
字号:
// returnbook.cpp : implementation file
//

#include "stdafx.h"
#include "图书馆管理系统.h"
#include "returnbook.h"
#include "client.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// returnbook dialog

returnbook::returnbook(CWnd* pParent /*=NULL*/)
	: CDialog(returnbook::IDD, pParent)
{
	//{{AFX_DATA_INIT(returnbook)
	m_list = -1;
	//}}AFX_DATA_INIT
}


void returnbook::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(returnbook)
	DDX_Control(pDX, IDC_RETURNLIST, m_returnlist);
	DDX_LBIndex(pDX, IDC_RETURNLIST, m_list);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(returnbook, CDialog)
	//{{AFX_MSG_MAP(returnbook)
	ON_BN_CLICKED(IDD_ABOUTBOX15, OnAboutbox15)
	ON_BN_CLICKED(IDD_ABOUTBOX14, OnRETURN)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// returnbook message handlers

void returnbook::OnAboutbox15() 
{
	// TODO: Add your control notification handler code here
	CDialog::OnCancel();
}

void returnbook::OnRETURN() 
{
	// TODO: Add your control notification handler code here

    int i=0;
	CString str;
	CFile file;

	int math_i=m_returnlist.GetCurSel();
    m_returnlist.DeleteString(math_i); 

	file.Open(m_path,CFile::modeWrite|CFile::modeCreate);
	for ( i;i<m_returnlist.GetCount();i++)
	{
		m_returnlist.GetText(i,str);
		if(str == "\n")
			continue;

		file.Write(str+"&",str.GetLength()+1);

	}
     MessageBox("Success!");
	
	file.Close();


}

BOOL returnbook::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	
	CFile file;
	CString temp;
	char t[1];
	
	file.Open(m_path,CFile::modeRead);
	///////////////////////读文档
    while (file.Read(t,1))
	{
		
      if(t[0] == '&')
	  {
		 temp+='\n';
	    typelist=temp;
		m_returnlist.AddString(typelist);
	
		 temp = "";
		 continue;
	  }
	  temp+=t[0];

	}
  UpdateData(1);
   	file.Close();
    //////////////////////读完文档

	return FALSE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -