zoukankan      html  css  js  c++  java
  • FireDAC 应用 (主从表关系)



    1
    //--------------------------------------------------------------------------- 2 3 // This software is Copyright (c) 2015 Embarcadero Technologies, Inc. 4 // You may only use this software if you are an authorized licensee 5 // of an Embarcadero developer tools product. 6 // This software is considered a Redistributable as defined under 7 // the software license agreement that comes with the Embarcadero Products 8 // and is subject to that software license agreement. 9 10 //--------------------------------------------------------------------------- 11 // 这里可以通过界面的设置,生成对应的主从关系 12 unit fMasterDetail; 13 14 interface 15 16 uses 17 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 18 Dialogs, DB, StdCtrls, ExtCtrls, Grids, DBGrids, Buttons, ComCtrls, 19 fMainCompBase, 20 FireDAC.Stan.Intf, FireDAC.DatS, FireDAC.Stan.Option, FireDAC.Stan.Param, 21 FireDAC.Phys.Intf, 22 FireDAC.DApt.Intf, 23 FireDAC.Comp.Client, FireDAC.Comp.DataSet, FireDAC.Stan.Error; 24 25 type 26 TfrmMasterDetail = class(TfrmMainCompBase) 27 cdsOrders: TFDMemTable; 28 cdsOrdDetails: TFDMemTable; 29 dsOrders: TDataSource; 30 DBGrid1: TDBGrid; 31 DBGrid2: TDBGrid; 32 dsOrdDetails: TDataSource; 33 Splitter1: TSplitter; 34 adOrders: TFDTableAdapter; 35 adOrderDetails: TFDTableAdapter; 36 cmOrders: TFDCommand; 37 cmOrderDetails: TFDCommand; 38 chbFetchOnDemand: TCheckBox; 39 pnlFetchOnDemand: TPanel; 40 Button1: TButton; 41 Button2: TButton; 42 procedure cbDBClick(Sender: TObject); 43 procedure chbFetchOnDemandClick(Sender: TObject); 44 procedure Button1Click(Sender: TObject); 45 procedure Button2Click(Sender: TObject); 46 private 47 { Private declarations } 48 public 49 { Public declarations } 50 end; 51 52 var 53 frmMasterDetail: TfrmMasterDetail; 54 55 implementation 56 57 uses 58 dmMainComp; 59 60 {$R *.dfm} 61 62 procedure TfrmMasterDetail.cbDBClick(Sender: TObject); 63 begin 64 with dmlMainComp.dbMain.FetchOptions do 65 Items := Items - [fiMeta]; 66 67 cdsOrders.Close; 68 cdsOrdDetails.Close; 69 inherited cbDBClick(Sender); 70 cdsOrders.Active := True; 71 cdsOrdDetails.Active := True; 72 end; 73 74 procedure TfrmMasterDetail.chbFetchOnDemandClick(Sender: TObject); 75 begin 76 // In this mode the client dataset fetches additional packets of data as needed (for example, 77 // as a user scrolls through data, or conducts a search). 78 if chbFetchOnDemand.Checked then 79 cdsOrders.FetchOptions.Mode := fmOnDemand 80 else 81 cdsOrders.FetchOptions.Mode := fmManual; 82 if chbFetchOnDemand.Checked then 83 cdsOrdDetails.FetchOptions.Mode := fmOnDemand 84 else 85 cdsOrdDetails.FetchOptions.Mode := fmManual; 86 end; 87 88 procedure TfrmMasterDetail.Button1Click(Sender: TObject); 89 begin 90 cdsOrders.ApplyUpdates(); 91 cdsOrdDetails.ApplyUpdates(); 92 end; 93 94 procedure TfrmMasterDetail.Button2Click(Sender: TObject); 95 begin 96 cdsOrders.CancelUpdates(); 97 cdsOrdDetails.CancelUpdates(); 98 cdsOrders.Refresh; 99 cdsOrdDetails.Refresh; 100 end; 101 102 end.
  • 相关阅读:
    查询两门及其以上不及格课程的同学的学号,姓名及其平均成绩 从SC表中选取score小于60的,并group by sid,having count 大于1
    SQL经典实例书上的数据代码
    mysql练习题
    mysql中alter语句
    如何解决SSH登录Solaris主机速度慢的问题
    Solaris10安装配置LDAP(iPlanet Directory Server )
    Oracle 11g oracle 用户密码过期问题 (ZT)
    Changing Controller Numbers in Solaris
    SPARC T4 RAID Setup (ZT)
    Oracle11g 配置DG broker
  • 原文地址:https://www.cnblogs.com/fehdd/p/6386206.html
Copyright © 2011-2022 走看看