?? tszhiliao.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 + -