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

📄 dezhe.cpp

📁 一个简单的图书管理系统
💻 CPP
字号:
// dezhe.cpp : implementation file
//

#include "stdafx.h"
#include "图书管理系统.h"
#include "dezhe.h"
#include <fstream.h>
#include <string.h>

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

/////////////////////////////////////////////////////////////////////////////
// dezhe dialog
int chong(unsigned int);
  	struct duzhe
	{
		int number;
		char name[20];
		int telephonenumber;
		int borrownumber;
	};


dezhe::dezhe(CWnd* pParent /*=NULL*/)
	: CDialog(dezhe::IDD, pParent)
{
	//{{AFX_DATA_INIT(dezhe)
	haoma = 0;
	xingming = _T("");
	tele = 0;
	numjie = 0;
	//}}AFX_DATA_INIT
}


void dezhe::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(dezhe)
	DDX_Text(pDX, IDC_EDIT1, haoma);
	DDX_Text(pDX, IDC_EDIT2, xingming);
	DDX_Text(pDX, IDC_EDIT3, tele);
	DDX_Text(pDX, IDC_EDIT4, numjie);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(dezhe, CDialog)
	//{{AFX_MSG_MAP(dezhe)
	ON_EN_CHANGE(IDC_EDIT1, Ondzxx1)
	ON_EN_CHANGE(IDC_EDIT2, Ondzxx2)
	ON_EN_CHANGE(IDC_EDIT3, Ondzxx3)
	ON_EN_CHANGE(IDC_EDIT4, Ondzxx4)
	ON_NOTIFY(NM_CLICK, IDC_LIST1, Onyjsm)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_NOTIFY(MCN_GETDAYSTATE, IDC_MONTHCALENDAR1, OnGetdaystateMonthcalendar1)
	ON_BN_CLICKED(IDC_BUTTON2, Onqx2)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// dezhe message handlers

void dezhe::Ondzxx1() 
{
	// 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
	
}

void dezhe::Ondzxx2() 
{
	// 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
	
}

void dezhe::Ondzxx3() 
{
	// 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
	
}

void dezhe::Ondzxx4() 
{
	// 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
	
}

void dezhe::Onyjsm(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	
	*pResult = 0;
}

void dezhe::OnButton1() 
{
	UpdateData(true);
	// TODO: Add your control notification handler code here
	struct duzhe person;
	person.number=haoma;
	strcpy(person.name,xingming);
	person.telephonenumber=tele;
	person.borrownumber=numjie;
	

if (chong(person.number) == 0)
{
	ofstream ofile("duzhe.dat", ios::app);
	ofile.write((char *)&person, sizeof(duzhe));
	ofile.close();
	MessageBox("录入成功");

	
	
}
else
	this->MessageBox("输入的学号已存在,请重新输入!","消息");

    xingming="";
	haoma=0;
    UpdateData(false);
}
int chong(unsigned int num)
{
	struct duzhe person1;
	ifstream ifile("duzhe.dat", ios::in);
	while(!ifile.eof())
	{
		ifile.read((char *)&person1, sizeof(duzhe));
		if (num== (unsigned int)person1.number)
			return 1;
	//	ifile.close();
	}
	return 0;

	
}

void dezhe::OnGetdaystateMonthcalendar1(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	
	*pResult = 0;
}

void dezhe::Onqx2() 
{
	// TODO: Add your control notification handler code here
	
}

⌨️ 快捷键说明

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