frmqrysp.cpp

来自「《C Builder 5程序设计——数据库应用实务篇》程序源代码」· C++ 代码 · 共 58 行

CPP
58
字号
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop

#include "Frmqrysp.h"
#include "DmCSDemo.h"
//---------------------------------------------------------------------------
#pragma resource "*.dfm"
TFrmQueryProc *FrmQueryProc;
//---------------------------------------------------------------------------
__fastcall TFrmQueryProc::TFrmQueryProc(TComponent* Owner)
  : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void TFrmQueryProc::WriteMsg(char *szWrite)
{
   StatusBar1->SimpleText = szWrite;
}
//---------------------------------------------------------------------------
void __fastcall TFrmQueryProc::FormShow(TObject *Sender)
{
  DmEmployee->EmployeeTable->Open();
  // Allow data flow from the EmployeeTable to the local EmployeeSource.  This
  //   will allow DataChange events to execute the query procedure
  EmployeeSource->Enabled = True;
  // Explicit query preparation is not required, but gives the best possible
  //  performance
  if (EmployeeProjectsQuery->Active != True)
     EmployeeProjectsQuery->Prepare();
}
//---------------------------------------------------------------------
void __fastcall TFrmQueryProc::EmployeeSourceDataChange(TObject *Sender,
      TField *Field)
{

  // Execute the ProjectsQuery, which uses a query procedure
  EmployeeProjectsQuery->Close();
  EmployeeProjectsQuery->ParamByName("EMP_NO")->AsSmallInt =
    DmEmployee->EmployeeTableEMP_NO->Value;
  EmployeeProjectsQuery->Open();

  String buf = "Employee "
             + String((int)DmEmployee->EmployeeTableEMP_NO->Value)
             + " is assigned to " 
             + String((int)EmployeeProjectsQuery->RecordCount)
             + " project(s)";
  WriteMsg(buf.c_str());
} 
//---------------------------------------------------------------------
void __fastcall TFrmQueryProc::FormHide(TObject *Sender)
{
   // Turn off the DataChange event for the form, since DmEmployee.EmployeeTable
   // is used elsewhere
   EmployeeSource->Enabled = True;
}
//---------------------------------------------------------------------

⌨️ 快捷键说明

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