📄 stuinfo.~cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include"TPerson.h"
#include "StuInfo.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm8 *Form8;
//---------------------------------------------------------------------------
__fastcall TForm8::TForm8(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm8::Button2Click(TObject *Sender)
{
this->Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm8::Button1Click(TObject *Sender)
{
if(this->Edit2->Text.Length() !=10||this->Edit1->Text.IsEmpty())
ShowMessage("帐号或其他不正确,请输入正确信息");
else
{
int n=0;
int i=0;
Person *New=NewStudent();
Person *old=NewStudent(this->Edit1->Text,StrToInt(this->Edit6->Text),this->RadioButton1->Checked);
old->SetAddress(this->Edit5->Text );
old->SetPhone(this->Edit4->Text);
old->SetNO(this->Edit2->Text);
old->SetClass(this->Edit3->Text) ;
FILE *fp=NULL;
fp=fopen("e:\\c\\student","rb+");
if(fp==NULL) ShowMessage("不明错误");
else
{
while (!feof(fp))
{
New->Read(fp); //Tread(fp,New);
n++;
if(New->GetNO() ==old->GetNO() )
{
i=1;
ShowMessage("finded");
break;
}
}
if(i==1)
{
fseek(fp,(n-1)*sizeof(char[111]),SEEK_SET);
old->Write(fp); //Twrite(fp,old);
ShowMessage("有记录,更新保存成功");
}
else
{
old->Write(fp); //Twrite(fp,old);
ShowMessage("保存成功!!");
}
}
fclose(fp);
delete New;
delete old;
}
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -