📄 zmlocate.pas
字号:
ParamByName('@dwbh').AsString := IntToStr(P_SelectSfNo);
ParamByName('@htbh').AsString := Trim(suiEdit1.Text);
if suiCheckBox1.Checked then
begin
ParamByName('@qdrq1').AsString := FormatDateTime('YYYY-MM-DD',dtp1.Date);
ParamByName('@qdrq2').AsString := FormatDateTime('YYYY-MM-DD',dtp2.Date);
end
else
begin
ParamByName('@qdrq1').AsString := '';
ParamByName('@qdrq2').AsString := '';
end;
if suiCheckBox2.Checked then
begin
ParamByName('@skrq1').AsString := FormatDateTime('YYYY-MM-DD',dtp3.Date);
ParamByName('@skrq2').AsString := FormatDateTime('YYYY-MM-DD',dtp4.Date);
end
else
begin
ParamByName('@skrq1').AsString := '';
ParamByName('@skrq2').AsString := '';
end;
if suiCheckBox3.Checked then
begin
ParamByName('@fhrq1').AsString := FormatDateTime('YYYY-MM-DD',dtp5.Date);
ParamByName('@fhrq2').AsString := FormatDateTime('YYYY-MM-DD',dtp6.Date);
end
else
begin
ParamByName('@fhrq1').AsString := '';
ParamByName('@fhrq2').AsString := '';
end;
ParamByName('@fhdh').AsString := Trim(suiEdit2.Text);
ParamByName('@ckdh').AsString := Trim(suiEdit3.Text);
try
Active := true ;
except
on E : Exception do
begin
with suiMessageDialog1 do
begin
ButtonCount := 1;
Button1Caption := '确定';
Caption := suiForm1.Caption ;
Text := '查询错误:'+E.Message + Chr(10)+Chr(13) ;
IconType := suiStop ;
ShowModal ;
Abort ;
end;
end;
end;
tbl_fjhtqkb.Active := True ;
tbl_fhqkb.Active := True ;
tbl_kpqkb.Active := true ;
tbl_fjkpqkb.Active := true ;
tbl_skqkb.Active := true ;
end;}
SQLSyx := 'Select * from 基本合同信息表';
SubSQLSyx := 'Select 合同编号 from 发货情况表';
if SelectSfNo > 0 then
if AnsiPos('Where',SQLSyx) > 0 then
SQLSyx := SQLSyx + ' And 省级编号 = ' + IntToStr(SelectSfNo)
else
SQLSyx := SQLSyx + ' Where 省级编号 = ' + IntToStr(SelectSfNo) ;
if SelectDwNo > 0 then
if AnsiPos('Where',SQLSyx) > 0 then
SQLSyx := SQLSyx + ' And 单位编号 = ' + IntToStr(SelectDwNo)
else
SQLSyx := SQLSyx + ' Where 单位编号 = ' + IntToStr(SelectDwNo) ;
if Trim(suiEdit1.Text) <> '' then
if AnsiPos('Where',SQLSyx) > 0 then
SQLSyx := SQLSyx + ' And 合同编号 like ''%'+
Trim(suiEdit1.Text)+'%'''
else
SQLSyx := SQLSyx + ' Where 合同编号 like ''%'+
Trim(suiEdit1.Text)+'%''';
if suiCheckBox1.Checked then
if AnsiPos('Where',SQLSyx) > 0 then
SQLSyx := SQLSyx + ' And 签订日期 Between '''+
FormatDateTime('YYYY-MM-DD',dtp1.Date)+''' And '''+
FormatDateTime('YYYY-MM-DD',dtp2.Date)+''''
else
SQLSyx := SQLSyx + ' Where 签订日期 Between '''+
FormatDateTime('YYYY-MM-DD',dtp1.Date)+''' And '''+
FormatDateTime('YYYY-MM-DD',dtp2.Date)+'''';
if suiCheckBox2.Checked then
if AnsiPos('Where',SQLSyx) > 0 then
SQLSyx := SQLSyx + ' And 合同收款时间 Between '''+
FormatDateTime('YYYY-MM-DD',dtp3.Date)+''' And '''+
FormatDateTime('YYYY-MM-DD',dtp4.Date)+''''
else
SQLSyx := SQLSyx + ' Where 合同收款时间 Between '''+
FormatDateTime('YYYY-MM-DD',dtp3.Date)+''' And '''+
FormatDateTime('YYYY-MM-DD',dtp4.Date)+'''';
//==========子查询
if suiCheckBox3.Checked then
if AnsiPos('Where',SQLSyx) > 0 then
SubSQLSyx := SubSQLSyx + ' And 发货日期 Between '''+
FormatDateTime('YYYY-MM-DD',dtp5.Date)+''' And '''+
FormatDateTime('YYYY-MM-DD',dtp6.Date)+''''
else
SubSQLSyx := SubSQLSyx + ' Where 发货日期 Between '''+
FormatDateTime('YYYY-MM-DD',dtp5.Date)+''' And '''+
FormatDateTime('YYYY-MM-DD',dtp6.Date)+'''';
if suiCheckBox4.Checked then
if AnsiPos('Where',SQLSyx) > 0 then
SubSQLSyx := SubSQLSyx + ' And 发货单号 like ''' + Trim(suiEdit2.Text) + '%'''
else
SubSQLSyx := SubSQLSyx + ' Where 发货单号 like ''' + Trim(suiEdit2.Text) + '%''';
if suiCheckBox5.Checked then
if AnsiPos('Where',SQLSyx) > 0 then
SubSQLSyx := SubSQLSyx + ' And 出库单号 like ''' + Trim(suiEdit3.Text) + '%'''
else
SubSQLSyx := SubSQLSyx + ' Where 出库单号 like ''' + Trim(suiEdit3.Text) + '%''';
if ((suiCheckBox3.Checked) or (suiCheckBox4.Checked) or (suiCheckBox5.Checked)) then
if AnsiPos('Where',SQLSyx) > 0 then
SQLSyx := SQLSyx + ' And 合同编号 in (' + SubSQLSyx + ')'
else
SQLSyx := SQLSyx + ' Where 合同编号 in (' + SubSQLSyx + ')' ;
suiStatusBar1.SimpleText := SQLSyx ;
suiStatusBar1.Hint := SQLSyx ;
with qry_Jbhtqkb do
begin
Close ;
SQL.Clear ;
SQL.Add(SQLSyx);
try
Active := True ;
tbl_fjhtqkb.Active := True ;
tbl_fhqkb.Active := True ;
tbl_kpqkb.Active := true ;
tbl_fjkpqkb.Active := true ;
tbl_skqkb.Active := true ;
BtnPrint.Enabled := RecordCount > 0 ;
except
on E : Exception do
begin
with suiMessageDialog1 do
begin
ButtonCount := 1;
Button1Caption := '确定';
Caption := suiForm1.Caption ;
Text := '查询错误:'+E.Message + Chr(10)+Chr(13)+'错误语法:'+SQLSyx ;
IconType := suiStop ;
ShowModal ;
Abort ;
end;
end;
end;
end;
end;
procedure TFrmZmLocate.FormKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
begin
Key := #0 ;
Perform(WM_NEXTDLGCTL,0,0);
end;
end;
procedure TFrmZmLocate.suiCheckBox1Click(Sender: TObject);
begin
dtp1.Enabled := suiCheckBox1.Checked ;
dtp2.Enabled := suiCheckBox1.Checked ;
end;
procedure TFrmZmLocate.suiCheckBox2Click(Sender: TObject);
begin
dtp3.Enabled := suiCheckBox2.Checked ;
dtp4.Enabled := suiCheckBox2.Checked ;
end;
procedure TFrmZmLocate.suiComboBox2Change(Sender: TObject);
var Str : String;
Pos : Integer ;
begin
Str := Trim(suiComboBox2.Text);
Pos := AnsiPos('-',Str);
if Pos <= 0 then
begin
SelectDwNo := -1 ;
SelectDwMc := '未选择';
end
else
begin
SelectDwNo := StrToInt(Copy(Str,1,Pos-1));
SelectDwMc := Copy(Str,Pos+1,Length(Str)-Pos);
end;
end;
procedure TFrmZmLocate.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
tbl_fjhtqkb.Active := False ;
tbl_fhqkb.Active := False ;
tbl_kpqkb.Active := False ;
tbl_fjkpqkb.Active := False ;
tbl_skqkb.Active := False ;
qry_jbhtqkb.Active := False ;
tbl_sjxxb.Active := False ;
tbl_dwxxb.Active := False ;
tbl_spxxb.Active := False ;
{ with DataModule1 do
begin
tbl_Fjhtqkb.Open ;
tbl_Kpqkb.Open ;
tbl_Fhqkb.Open ;
tbl_Skqkb.Open ;
tbl_Fjkpqkb.Open ;
tbl_dwxxb.Close ;
tbl_dwxxb.MasterSource := OldDataSource ;
tbl_dwxxb.MasterFields := OldFieldName ;
tbl_dwxxb.Open ;
end;}
end;
procedure TFrmZmLocate.BtnPrintClick(Sender: TObject);
var
Report: TfrReport;
FrmPreview : TFrmPreview;
prtFileName : string;
begin
prtFileName := SysPath + 'prt\Print.frf';
if not FileExists(prtFileName) then raise Exception.Create('无效的报表配置文件');
Report := frReport1;
Report.LoadFromFile(prtFileName);
FrmPreview := TFrmPreview.Create(self);
Report.Preview := FrmPreview.frPreview1;
if Report.PrepareReport then
begin
Report.ShowPreparedReport;
FrmPreview.ShowModal;
end;
FrmPreview.Free ;
end;
//==========传递报表参数
procedure TFrmZmLocate.frReport1GetValue(const ParName: String;
var ParValue: Variant);
begin
if ParName = 'RptTitleTime' then
begin
if suiCheckBox1.Checked then
ParValue := FormatDateTime('YYYY-MM-DD',dtp1.Date)+'日~'+
FormatDateTime('YYYY-MM-DD',dtp2.Date)+'日'
else
ParValue := '缺省';
end
else if ParName = 'RptOtherTime' then
begin
if suiCheckBox2.Checked then
ParValue := FormatDateTime('YYYY-MM-DD',dtp3.Date)+'日~'+
FormatDateTime('YYYY-MM-DD',dtp4.Date)+'日'
else
ParValue := '缺省';
end
else if ParName = 'RptSf' then
ParValue := suiComboBox1.Text
else if ParName = 'RptDw' then
ParValue := suiComboBox2.Text ;
end;
procedure TFrmZmLocate.suiCheckBox3Click(Sender: TObject);
begin
dtp5.Enabled := suiCheckBox3.Checked ;
dtp6.Enabled := suiCheckBox3.Checked ;
end;
procedure TFrmZmLocate.suiCheckBox4Click(Sender: TObject);
begin
suiEdit2.Enabled := suiCheckBox4.Checked ;
if suiEdit2.Enabled then suiEdit2.SetFocus ;
end;
procedure TFrmZmLocate.suiCheckBox5Click(Sender: TObject);
begin
suiEdit3.Enabled := suiCheckBox5.Checked ;
if suiEdit3.Enabled then suiEdit3.SetFocus ;
end;
procedure TFrmZmLocate.tbl_fjhtqkbCalcFields(DataSet: TDataSet);
begin
with DataSet do
FieldByName('金额').AsFloat := FieldByName('数量').AsInteger * FieldByName('单价').AsFloat ;
end;
procedure TFrmZmLocate.tbl_fjkpqkbCalcFields(DataSet: TDataSet);
begin
with DataSet do
FieldByName('开票金额').AsFloat := FieldByName('开票数量').AsInteger *
FieldByName('开票单价').AsFloat ;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -