//新增时写的事件.... procedure TMainForm.btnNewClick(Sender: TObject); begin inherited; if (MainForm.ActiveMDIChild is TTwoForm) then //主从档的 begin try with MainForm.ActiveMDIChild as TTwoForm do begin Detail.Append; Master.Append; end; except end; end; end; //保存时的事件.... procedure TMainForm.btnSaveClick(Sender: TObject); begin inherited; if (MainForm.ActiveMDIChild is TTwoForm) then //主从档的 begin try with MainForm.ActiveMDIChild as TTwoForm do begin if (Master.State in [dsinsert,dsEdit]) then begin Detail.UpdateBatch(arAllChapters); Master.UpdateBatch(arAllChapters); SetConReadOnly(MainForm.ActiveMDIChild as TTwoForm, true); end; end; except end; end; end;
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, UBDSFrm, Grids, DBGridEh, ADODB, DB, DataFilterForDate,
ExtCtrls, ComCtrls,Menus, ppProd, ppClass, ppReport, ppComm, ppRelatv,
ppDB, ppDBPipe, ppVar, ppPrnabl, ppCtrls, ppBands, ppCache, ppParameter;type
TTwoForm = class (TAssertForm)
DDS: TDataSource;
DBGridEh2: TDBGridEh;
Detail: TADOQuery;
ppDBPipeline2: TppDBPipeline;
procedure DetailNewRecord(DataSet: TDataSet);
private
protected
end;implementationuses Main, SysBasDM, SysPublic;{$R *.dfm}procedure TTwoForm.DetailNewRecord(DataSet: TDataSet);
begin
inherited;
Detail.FieldByName('Item_Num').AsInteger := Detail.RecordCount + 1;
Detail.FieldByName('Single_No').AsString :=Master.FieldByName('Single_No').AsString;
end;end.
procedure TMainForm.btnNewClick(Sender: TObject);
begin
inherited;
if (MainForm.ActiveMDIChild is TTwoForm) then //主从档的
begin
try
with MainForm.ActiveMDIChild as TTwoForm do
begin
Detail.Append;
Master.Append;
end;
except
end;
end;
end;
//保存时的事件....
procedure TMainForm.btnSaveClick(Sender: TObject);
begin
inherited;
if (MainForm.ActiveMDIChild is TTwoForm) then //主从档的
begin
try
with MainForm.ActiveMDIChild as TTwoForm do
begin
if (Master.State in [dsinsert,dsEdit]) then
begin
Detail.UpdateBatch(arAllChapters);
Master.UpdateBatch(arAllChapters);
SetConReadOnly(MainForm.ActiveMDIChild as TTwoForm, true);
end;
end;
except
end;
end;
end;