home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 April / Chip_1997-04_cd.bin / prezent / cb / data.z / FRMQRYSP.CPP < prev    next >
C/C++ Source or Header  |  1997-01-16  |  2KB  |  61 lines

  1. //----------------------------------------------------------------------------
  2. //Borland C++ Builder
  3. //Copyright (c) 1987 Borland International Inc. All Rights Reserved.
  4. //----------------------------------------------------------------------------
  5. //---------------------------------------------------------------------------
  6. #include <vcl.h>
  7. #pragma hdrstop
  8.  
  9. #include "Frmqrysp.h"
  10. #include "DmCSDemo.h"
  11. //---------------------------------------------------------------------------
  12. #pragma resource "*.dfm"
  13. TFrmQueryProc *FrmQueryProc;
  14. //---------------------------------------------------------------------------
  15. __fastcall TFrmQueryProc::TFrmQueryProc(TComponent* Owner)
  16.   : TForm(Owner)
  17. {
  18. }
  19. //---------------------------------------------------------------------------
  20. void TFrmQueryProc::WriteMsg(char *szWrite)
  21. {
  22.    StatusBar1->SimpleText = szWrite;
  23. }
  24. //---------------------------------------------------------------------------
  25. void __fastcall TFrmQueryProc::FormShow(TObject *Sender)
  26. {
  27.   DmEmployee->EmployeeTable->Open();
  28.   // Allow data flow from the EmployeeTable to the local EmployeeSource.  This
  29.   //   will allow DataChange events to execute the query procedure
  30.   EmployeeSource->Enabled = True;
  31.   // Explicit query preparation is not required, but gives the best possible
  32.   //  performance
  33.   if (EmployeeProjectsQuery->Active != True)
  34.      EmployeeProjectsQuery->Prepare();
  35. }
  36. //---------------------------------------------------------------------
  37. void __fastcall TFrmQueryProc::EmployeeSourceDataChange(TObject *Sender,
  38.       TField *Field)
  39. {
  40.   char szMsg[300];
  41.  
  42.   // Execute the ProjectsQuery, which uses a query procedure
  43.   EmployeeProjectsQuery->Close();
  44.   EmployeeProjectsQuery->ParamByName("EMP_NO")->AsSmallInt =
  45.     DmEmployee->EmployeeTableEMP_NO->Value;
  46.   EmployeeProjectsQuery->Open();
  47.  
  48.   sprintf(szMsg, "Employee %d is assigned to %d project(s)",
  49.           DmEmployee->EmployeeTableEMP_NO->Value,
  50.           EmployeeProjectsQuery->RecordCount);
  51.   WriteMsg(szMsg);
  52. }
  53. //---------------------------------------------------------------------
  54. void __fastcall TFrmQueryProc::FormHide(TObject *Sender)
  55. {
  56.    // Turn off the DataChange event for the form, since DmEmployee.EmployeeTable
  57.    // is used elsewhere
  58.    EmployeeSource->Enabled = True;
  59. }
  60. //---------------------------------------------------------------------
  61.