salary_i.cpp

来自「C++Builde5程序设计—基础教学篇程序源代码1。」· C++ 代码 · 共 54 行

CPP
54
字号
//-------------  salary_i  --------------------------------------------------------------
#include <stdio.h>
#include<io.h>
#include "salary_i.h"
#include "salary_m.h"
#include <vcl.h>
#pragma hdrstop
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
struct employee_struct
{
  int order;
  char name[12];
  int salary;
  int add;
};
employee_struct employee;
int total_record;
FILE *file1;
TfrmSalaryInquire *frmSalaryInquire;
//---------------------------------------------------------------------------
__fastcall TfrmSalaryInquire::TfrmSalaryInquire(TComponent* Owner)
    : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmSalaryInquire::FormActivate(TObject *Sender)
{
  char *file_name="a:/ch14/salary.mny";
  file1=fopen(file_name,"a+");
  total_record=filelength(fileno(file1))/sizeof(employee)+1;
  edtOrder->Text="";
  edtName->Text="";
  edtSalary->Text="";
  edtAdd->Text="";
  edtTotal->Text="";
  edtOrder->SetFocus();
}
//---------------------------------------------------------------------------
void __fastcall TfrmSalaryInquire::edtOrderKeyPress(TObject *Sender,
      char &Key)
{
  if( Key == 13 ) { btnOKClick(Sender);}
}
//---------------------------------------------------------------------------
void __fastcall TfrmSalaryInquire::btnOKClick(TObject *Sender)
{
  int order;
  order=StrToInt(edtOrder->Text);
  if( order < 0 || order >= total_record)
    {
       edtOrder->Text="";
       edtName->Text="

⌨️ 快捷键说明

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