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

📄 tszhiliao.cpp

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

#include "stdafx.h"
#include "图书管理系统.h"
#include "tszhiliao.h"
#include <fstream.h>
#include <string.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
int chong1(unsigned int);
  	struct tu
	{
		int bianmaa;
		char mingchenga[20];
		int kucuna;
		int zongceshua;
	}tus[50];
/////////////////////////////////////////////////////////////////////////////
// tszhiliao dialog


tszhiliao::tszhiliao(CWnd* pParent /*=NULL*/)
	: CDialog(tszhiliao::IDD, pParent)
{
	//{{AFX_DATA_INIT(tszhiliao)
	bianma = 0;
	mingcheng = _T("");
	kucun = 0;
	zongceshu = 0;
	//}}AFX_DATA_INIT
}


void tszhiliao::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(tszhiliao)
	DDX_Text(pDX, IDC_EDIT1, bianma);
	DDX_Text(pDX, IDC_EDIT2, mingcheng);
	DDX_Text(pDX, IDC_EDIT3, kucun);
	DDX_Text(pDX, IDC_EDIT4, zongceshu);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(tszhiliao, CDialog)
	//{{AFX_MSG_MAP(tszhiliao)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// tszhiliao message handlers

void tszhiliao::OnButton1() 
{
	// TODO: Add your control notification handler code here
	UpdateData(true);
	// TODO: Add your control notification handler code here
	struct tu tuzl;
	tuzl.bianmaa=bianma;
	strcpy(tuzl.mingchenga,mingcheng);
tuzl.kucuna=kucun;
	tuzl.zongceshua=zongceshu;

	ifstream ifile("tu.dat",ios::in);
	for(int s=0;s<50;s++)
		ifile.read((char *)&tus[s], sizeof(tu));
	  
	
	  for(int k=0;k<50;k++)
	  {
		  if(tus[k].bianmaa==bianma)
		  {
			  this->MessageBox("输入的学号已存在,请重新输入!","消息");
		           break;
		  }
				   else

			   for(int i=0;i<50;i++) 
              if(tus[i].bianmaa ==NULL)
			  {
	             tus[i].bianmaa =bianma;
	             strcpy(tus[i].mingchenga,mingcheng);
                tus[i].kucuna=kucun;
	            tus[i].zongceshua=zongceshu;
	 ofstream ofile("tu.dat", ios::app);
	  ofile.write((char *)&tus[i], sizeof(tu));
	  ofile.close();
	         this->MessageBox("录入成功");
	         goto loop;
		
			  }
	  }
loop:
    
			 
	  
/*if (chong1(tuzl.bianmaa) == 0)
{
	ofstream ofile("tu.dat", ios::app);
	ofile.write((char *)&tuzl, sizeof(tu));
	ofile.close();
	

	
	
}
else
	this->MessageBox("输入的学号已存在,请重新输入!","消息");
*/
    mingcheng="";
bianma=0;
    UpdateData(false);
}
/*int chong1(unsigned int num)
{
	struct tu tuzl1;
	ifstream ifile("tu.dat", ios::in);
	while(!ifile.eof())
	{
		ifile.read((char *)&tuzl1, sizeof(tu));
		if (num== (unsigned int)tuzl1.bianmaa)
			return 1;
	//	ifile.close();
	}
	return 0;
	
}
*/

⌨️ 快捷键说明

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