CompaniesData.pas
上传用户:fh681027
上传日期:2022-07-23
资源大小:1959k
文件大小:2k
源码类别:

Delphi控件源码

开发平台:

Delphi

  1. unit CompaniesData;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  5.   Db, IBCustomDataSet, IBDatabase;
  6. type
  7.   TDmCompanies = class(TDataModule)
  8.     DataCompanies: TIBDataSet;
  9.     DataLocations: TIBDataSet;
  10.     DataPeople: TIBDataSet;
  11.     dsCompanies: TDataSource;
  12.     IBTransaction1: TIBTransaction;
  13.     DataLocationsID: TIntegerField;
  14.     DataLocationsID_COMPANY: TIntegerField;
  15.     DataLocationsADDRESS: TIBStringField;
  16.     DataLocationsFAX: TIBStringField;
  17.     DataLocationsPHONE: TIBStringField;
  18.     DataLocationsSTATE: TIBStringField;
  19.     DataLocationsTOWN: TIBStringField;
  20.     DataLocationsZIP: TIBStringField;
  21.     DataPeopleID: TIntegerField;
  22.     DataPeopleID_COMPANY: TIntegerField;
  23.     DataPeopleID_LOCATION: TIntegerField;
  24.     DataPeopleKEY_CONTACT: TIBStringField;
  25.     DataPeopleNAME: TIBStringField;
  26.     DataPeopleEMAIL: TIBStringField;
  27.     DataPeopleFAX: TIBStringField;
  28.     DataPeoplePHONE: TIBStringField;
  29.     DataCompaniesID: TIntegerField;
  30.     DataCompaniesNAME: TIBStringField;
  31.     DataCompaniesTAX_CODE: TIBStringField;
  32.     procedure DataLocationsAfterInsert(DataSet: TDataSet);
  33.     procedure DataPeopleAfterInsert(DataSet: TDataSet);
  34.   private
  35.     { Private declarations }
  36.   public
  37.     { Public declarations }
  38.   end;
  39. implementation
  40. uses
  41.   MainData;
  42. {$R *.DFM}
  43. procedure TDmCompanies.DataLocationsAfterInsert(DataSet: TDataSet);
  44. begin
  45.   // initialize the data of the detail record
  46.   // with a reference to the master record
  47.   DataLocationsID_COMPANY.AsInteger :=
  48.     DataCompaniesID.AsInteger;
  49. end;
  50. procedure TDmCompanies.DataPeopleAfterInsert(DataSet: TDataSet);
  51. begin
  52.   // initialize the data of the detail record
  53.   // with a reference to the master record
  54.   DataPeopleID_COMPANY.AsInteger :=
  55.     DataCompaniesID.AsInteger;
  56.   // the suggested location is the active one, if available
  57.   if not DataLocations.IsEmpty then
  58.     DataPeopleID_LOCATION.AsInteger :=
  59.       DataLocationsID.AsInteger;
  60.   // the first person added becomes the key contact
  61.   // (checks if the filtered dataset of people is empty)
  62.   DataPeopleKEY_CONTACT.AsBoolean := DataPeople.IsEmpty;
  63. end;
  64. end.