client.cpp

来自「基于MFC实现的图书管管理系统」· C++ 代码 · 共 130 行

CPP
130
字号
// client.cpp : implementation file
//

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

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

/////////////////////////////////////////////////////////////////////////////
// client dialog



client::client(CWnd* pParent /*=NULL*/)
	: CDialog(client::IDD, pParent)
{
	//{{AFX_DATA_INIT(client)
	m_skey = _T("");
	m_sid = _T("");
	//}}AFX_DATA_INIT
}


void client::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(client)
	DDX_Text(pDX, IDC_SKEY, m_skey);
	DDX_Text(pDX, IDC_SID, m_sid);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(client, CDialog)
	//{{AFX_MSG_MAP(client)
	ON_BN_CLICKED(IDD_ABOUTBOX8, OnAboutbox8)
	ON_BN_CLICKED(IDD_ABOUTBOX9, OnAboutbox9)
	ON_BN_CLICKED(IDD_ABOUTBOX10, OnAboutbox10)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// client message handlers


void client::OnAboutbox8() //borrow book
{
	// TODO: Add your control notification handler code here
	UpdateData (1);
    borrow dlg;

    if (m_sid.IsEmpty())
	MessageBox ("The ID is empty!","ERROR",MB_ICONSTOP);
	else {
		    m_path="Client\\"+m_sid+".txt";
            dlg.m_path=m_path;
           CFile student;

			if (!student.Open(m_path,CFile::modeCreate|CFile::modeNoTruncate))
				
			{  MessageBox ("Openning file error!");
			 	return;
			}
	
			student.Close();
			UpdateData(0);


	 if (m_skey=="1111")
	{ 
	  dlg.DoModal();
	  CDialog::OnCancel();
	  UpdateData(0);
	}
	else MessageBox ("The keyword is error!","ERROR",MB_ICONSTOP);
	m_sid="";
	m_skey="";
	 UpdateData(0);
	}

}
void client::OnAboutbox9() //returnbook
{
	// TODO: Add your control notification handler code here
	UpdateData (1);
	returnbook dlg;

	///////////////
	 if (m_sid.IsEmpty())
	MessageBox ("The ID is empty!","ERROR",MB_ICONSTOP);
	else {
		    m_path="Client\\"+m_sid+".txt";
			//dlg.m_path=m_path;
           CFile student;
           if (!student.Open(m_path,CFile::modeCreate|CFile::modeNoTruncate))
				
			{  MessageBox ("Openning file error!");
			 	return;
			}
		   student.Close();
			UpdateData(0);
		}

    ///////////////
	if (m_skey=="1111")
	{ dlg.m_path=m_path;
	  dlg.DoModal();
	  CDialog::OnCancel();
	  UpdateData(0);
	}
	else MessageBox ("The keyword is error!","ERROR",MB_ICONSTOP);
	m_sid="";
	m_skey="";
	 UpdateData(0);
	
}

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

⌨️ 快捷键说明

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