确实是被别的窗体调用的。
我是在别的窗体(A)中,调用本窗体(B)的。
A窗体的代码:
unit QCWTSP;
interface
uses
Business.System, Business.Forms, Business.Data, Business.Model;
type
TQCWTSP = class(TForm)
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
BitBtn1: TBitBtn;
DataSetBZSJJ1: TSQLDataSet;
DataSource1: TDataSource;
DataSetBZSJJ2: TSQLDataSet;
DataSetBZSJJ3: TSQLDataSet;
DataSetBZSJJ4: TSQLDataSet;
BitBtn2: TBitBtn;
DataGrid1: TDataGrid;
DataGrid2: TDataGrid;
DataSource2: TDataSource;
DocViewBar1: TDocViewBar;
BitBtn3: TBitBtn;
DataGrid2DWBH: TDataGridColumn;
DataGrid2SPBH: TDataGridColumn;
DataGrid2DWQM: TDataGridColumn;
DataGrid2SPQM: TDataGridColumn;
DataGrid2GG: TDataGridColumn;
DataGrid2XH: TDataGridColumn;
DataGrid2CD: TDataGridColumn;
DataGrid2DW: TDataGridColumn;
DataGrid2KCSL: TDataGridColumn;
DataGrid2DJ: TDataGridColumn;
DataGrid2JE: TDataGridColumn;
DataGrid2CBDJ: TDataGridColumn;
DataGrid2CBJE: TDataGridColumn;
DataGrid1SPBH: TDataGridColumn;
DataGrid1SPQM: TDataGridColumn;
DataGrid1GG: TDataGridColumn;
DataGrid1XH: TDataGridColumn;
DataGrid1CD: TDataGridColumn;
DataGrid1DW: TDataGridColumn;
DataGrid1Column7: TDataGridColumn;
DataGrid1Column8: TDataGridColumn;
DataGrid1Column9: TDataGridColumn;
procedure BizFormCreate(Sender: TObject);
procedure BizFormShow(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure Edit1Change(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
private
{private declarations}
public
{public declarations}
end;
implementation
var
dwForm : XZCT1.TDWXZ;
sgForm : TLRQCKC;
procedure TQCWTSP.BizFormCreate(Sender: TObject);
var
i : integer;
begin
DataSetBZSJJ2.Open;
DataSetBZSJJ2.First;
while not DataSetBZSJJ2.Eof do
begin
DataSetBZSJJ3.Open;
DataSetBZSJJ3.First;
while not DataSetBZSJJ3.Eof do
begin
i := 1;
if not DataSetBZSJJ1.Eof = false then
i := 1;
DataSetBZSJJ4.Open;
DataSetBZSJJ4.First;
while not DataSetBZSJJ4.Eof do
begin
if (DataSetBZSJJ4.FieldByName['SPBH'].AsString = DataSetBZSJJ3.FieldByName['SPXX_SPBH'].AsString) and (DataSetBZSJJ4.FieldByName['DWBH'].AsString = DataSetBZSJJ2.FieldByName['DWXX_DWBH'].AsString) then
begin
i := 0;
break;
end;
DataSetBZSJJ4.Next;
end;
DataSetBZSJJ4.Edit;
if i = 1 then
begin
DataSetBZSJJ4.Append;
DataSetBZSJJ4.FieldByName['DWBH'].AsString := DataSetBZSJJ2.FieldByName['DWXX_DWBH'].AsString;
DataSetBZSJJ4.FieldByName['DWQM'].AsString := DataSetBZSJJ2.FieldByName['DWXX_DWQM'].AsString;
DataSetBZSJJ4.FieldByName['SPBH'].AsString := DataSetBZSJJ3.FieldByName['SPXX_SPBH'].AsString;
DataSetBZSJJ4.FieldByName['SPQM'].AsString := DataSetBZSJJ3.FieldByName['SPXX_SPQM'].AsString;
DataSetBZSJJ4.FieldByName['GG'].AsString := DataSetBZSJJ3.FieldByName['SPXX_GG'].AsString;
DataSetBZSJJ4.FieldByName['CD'].AsString := DataSetBZSJJ3.FieldByName['SPXX_CD'].AsString;
DataSetBZSJJ4.FieldByName['XH'].AsString := DataSetBZSJJ3.FieldByName['SPXX_XH'].AsString;
DataSetBZSJJ4.FieldByName['DW'].AsString := DataSetBZSJJ3.FieldByName['SPXX_DW'].AsString;
end;
DataSetBZSJJ3.Next;
end;
DataSetBZSJJ2.Next;
end;
DataSetBZSJJ4.ApplyUpdates;
DataSetBZSJJ4.Close;
DataSetBZSJJ2.Close;
DataSetBZSJJ3.Close;
end;
procedure TQCWTSP.BizFormShow(Sender: TObject);
begin
DataSource1.DataSet.Open;
DataGrid1.ApplyBestFit(nil);
end;
procedure TQCWTSP.BitBtn1Click(Sender: TObject);
begin
dwForm := XZCT1.TDWXZ.Create(self.Context);
try
if dwForm.ShowModal = business.Forms.Controls.mrOk then
begin
DataGrid1.Visible := false;
DataGrid2.Visible := true;
DataSource2.DataSet.Open;
Edit1.Text := dwForm.DataSetBroker1.DataSet.FieldByName['DWXX_DWQM'].AsString;
end;
finally
dwForm.Free;
end;
end;
procedure TQCWTSP.Edit1Change(Sender: TObject);
begin
if Edit1.Text <> '全部单位' then
begin
DataSetBZSJJ4.Close;
DataSetBZSJJ4.SQLFilter := 'DWQM = '''+Edit1.Text+'''';
DataSetBZSJJ4.SQLFiltered := true;
DataSetBZSJJ4.Open;
DataGrid2.ApplyBestFit(nil);
end;
end;
procedure TQCWTSP.BitBtn2Click(Sender: TObject);
begin
if Edit1.Text = '全部单位' then
begin
Dialogs.ShowMessage('现在为所有单位合计值,不能修改,请先选择某一单位后修改!');
end
else
begin
sgForm := TLRQCKC.Create(self.Context);
if sgForm.ShowModal = Business.Forms.Controls.mrOk then
begin
DataSetBZSJJ4.Edit;
DataSetBZSJJ4.FieldByName['KCSL'].AsString := sgForm.Edit1.Text;
DataSetBZSJJ4.FieldByName['DJ'].AsString := sgForm.Edit2.Text;
DataSetBZSJJ4.FieldByName['JE'].AsString := sgForm.Edit3.Text;
DataSetBZSJJ4.FieldByName['CBDJ'].AsString := sgForm.Edit4.Text;
DataSetBZSJJ4.FieldByName['CBJE'].AsString := sgForm.Edit5.Text;
DataSetBZSJJ4.ApplyUpdates;
end;
end;
end;
procedure TQCWTSP.BitBtn3Click(Sender: TObject);
begin
close;
end;
end.
B窗体的代码:
unit LRQCKC;
interface
uses
Business.System, Business.Forms;
type
TLRQCKC = class(TForm)
Label1: TLabel;
GroupBox1: TGroupBox;
Bevel1: TBevel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
procedure Edit2Exit(Sender: TObject);
procedure Edit3Exit(Sender: TObject);
procedure Edit4Exit(Sender: TObject);
procedure Edit5Change(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure Edit1Exit(Sender: TObject);
procedure BizFormShow(Sender: TObject);
private
{private declarations}
public
{public declarations}
end;
implementation
procedure TLRQCKC.BitBtn1Click(Sender: TObject);
begin
ModalResult := business.Forms.Controls.mrOk;
end;
procedure TLRQCKC.Edit2Exit(Sender: TObject);
begin
Edit3.Text := SysUtils.IntToStr(SysUtils.StrToInt(Edit1.Text)*SysUtils.StrToInt(Edit2.Text));
end;
procedure TLRQCKC.Edit3Exit(Sender: TObject);
begin
if Edit1.Text = '0' then
Edit2.Text := '0'
else
Edit2.Text := SysUtils.FloatToStr(SysUtils.StrToInt(Edit3.Text)/SysUtils.StrToInt(Edit1.Text));
end;
procedure TLRQCKC.Edit4Exit(Sender: TObject);
begin
Edit5.Text := SysUtils.IntToStr(SysUtils.StrToInt(Edit1.Text)*SysUtils.StrToInt(Edit4.Text));
end;
procedure TLRQCKC.Edit5Change(Sender: TObject);
begin
if Edit1.Text = '0' then
Edit4.Text := '0'
else
Edit4.Text := SysUtils.FloatToStr(SysUtils.StrToInt(Edit5.Text)/SysUtils.StrToInt(Edit1.Text));
end;
procedure TLRQCKC.BitBtn2Click(Sender: TObject);
begin
close;
end;
procedure TLRQCKC.Edit1Exit(Sender: TObject);
begin
Edit3.Text := SysUtils.IntToStr(SysUtils.StrToInt(Edit1.Text)*SysUtils.StrToInt(Edit2.Text));
Edit5.Text := SysUtils.IntToStr(SysUtils.StrToInt(Edit1.Text)*SysUtils.StrToInt(Edit4.Text));
end;
procedure TLRQCKC.BizFormShow(Sender: TObject);
begin
BitBtn1.SetFocus;
end;
end.
代码全在这里,你们帮看一下。 |