home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1997 April
/
Chip_1997-04_cd.bin
/
prezent
/
cb
/
data.z
/
FRMQRYSP.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1997-01-16
|
2KB
|
61 lines
//----------------------------------------------------------------------------
//Borland C++ Builder
//Copyright (c) 1987 Borland International Inc. All Rights Reserved.
//----------------------------------------------------------------------------
//---------------------------------------------------------------------------
#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)
{
char szMsg[300];
// Execute the ProjectsQuery, which uses a query procedure
EmployeeProjectsQuery->Close();
EmployeeProjectsQuery->ParamByName("EMP_NO")->AsSmallInt =
DmEmployee->EmployeeTableEMP_NO->Value;
EmployeeProjectsQuery->Open();
sprintf(szMsg, "Employee %d is assigned to %d project(s)",
DmEmployee->EmployeeTableEMP_NO->Value,
EmployeeProjectsQuery->RecordCount);
WriteMsg(szMsg);
}
//---------------------------------------------------------------------
void __fastcall TFrmQueryProc::FormHide(TObject *Sender)
{
// Turn off the DataChange event for the form, since DmEmployee.EmployeeTable
// is used elsewhere
EmployeeSource->Enabled = True;
}
//---------------------------------------------------------------------