【delphi开源代码栏目提醒】:网学会员delphi开源代码为您提供checkproviderquery.pas参考,解决您在checkproviderquery.pas学习中工作中的难题,参考学习。
unit checkproviderquery;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, instorequery, DB, Grids, DBGrids, ComCtrls, StdCtrls, Buttons,
ExtCtrls;
type
Tf_checkproviderquery = class(Tf_instorequery)
procedure storagefieldChange(Sender: TObject); override;
procedure QueryClick(Sender: TObject);override;
private
{ Private declarations }
public
{ Public declarations }
end;
var
f_checkproviderquery: Tf_checkproviderquery;
implementation
uses data;
{$R *.dfm}
//当查询条件改变时,组合框中会显示相应的值
procedure Tf_checkproviderquery.storagefieldChange(Sender: TObject);
begin
StorageValue.Clear;
Case StorageField.ItemIndex of
0:
begin
With t_data.Query1 do
begin
Close;
SQL.Clear;
SQL.Add('select providername from tb_providerinfo');
Open;
end;
if t_data.Query1.RecordCount>0 then
begin
while not t_data.Query1.Eof do
begin
StorageValue.Items.Add(Trim(t_data.Query1.Fields[0].Value));
t_data.Query1.Next;
end;
end;
end;
1:
begin
With t_data.Query1 do
begin
Close;
SQL.Clear;
SQL.Add('select workername from tb_employeeinfo');
Open;
end;
if t_data.Query1.RecordCount>0 then
begin
while not t_data.Query1.Eof do
begin
StorageValue.Items.Add(Trim(t_data.Query1.Fields[0].Value));
t_data.Query1.Next;
end;
end;
end;
end;
end;
//处理查询按钮的单击事件
procedure Tf_checkproviderquery.QueryClick(Sender: TObject);
begin
if (Storagecon.Checked = True) or( Date.Checked = True) then //判断是否设置了查询条件
begin
if (Storagecon.Checked = True )and (Date.Checked = False)then //只按条件查询
begin
if(Trim(StorageField.Text)<>'')and(Trim(StorageValue.Text)<>'') then
begin
With t_data.Query2 do
begin
Close;
SQL.Clear;
SQL.Add('select * from tb_providercheck where ');
case Storagefield.ItemIndex of
0: SQL.Add('providername = :Value');
1: SQL.Add('checkman = :Value');
2: SQL.Add('checkid = :Value');
end;
Parameters.ParamByName('Value').Value := Trim(Storagevalue.Text);
Open;
end;
if t_data.Query2.RecordCount>0 then //如果有数据返回,按供应商统计结款金额
begin
With t_data.Query3 do
begin
Close;
SQL.Clear;
SQL.Add('Select sum(paymoney) as paymoney ,providername from tb_providercheck where ');
case Storagefield.ItemIndex of
0: SQL.Add('providername = :Value');
1: SQL.Add('checkman = :Value');
2: SQL.Add('checkid = :Value');
end;
SQL.Add(' Group by providername');
Parameters.ParamByName('Value').Value := Trim(Storagevalue.Text);
Open;
end;
Source1.DataSet := t_data.Query2;
Source2.DataSet := t_data.Query3;
end
else
begin
Application.MessageBox('没有找到符合条件的记录.','提示',64);
Source1.DataSet := Nil;
Source2.DataSet := Nil;
end;
end;
end
else if (Storagecon.Checked = False )and (Date.Checked = True)then //只按时间
查询 begin
With t_data.Query2 do
begin
Close;
SQL.Clear;
SQL.Add('select * from tb_providercheck where');
SQL.Add(' TimeDate >= :FromDate and Timedate < :ToDate');
Parameters.ParamByName('FromDate').Value := Trunc(FromDate.DateTime);
Parameters.ParamByName('ToDate').Value := Trunc(ToDate.DateTime)+1;
Open;
end;
if t_data.Query2.RecordCount>0 then
begin
With t_data.Query3 do
begin
Close;
SQL.Clear;
SQL.Add('Select sum(paymoney) as paymoney ,providername from tb_providercheck where ');
SQL.Add(' TimeDate >= :FromDate and Timedate < :ToDate');
SQL.Add(' Group by providername');
Parameters.ParamByName('FromDate').Value := Trunc(FromDate.DateTime);
Parameters.ParamByName('ToDate').Value := Trunc(ToDate.DateTime)+1;
Open;
end;
Source1.DataSet := t_data.Query2;
Source2.DataSet := t_data.Query3;
end
else
begin
Application.MessageBox('没有找到符合条件的记录.','提示',64);
Source1.DataSet := Nil;
Source2.DataSet := Nil;
end;
end
else //即按查询条件又按时间段查询
begin
if(Trim(StorageField.Text)<>'')and(Trim(StorageValue.Text)<>'') then
begin
With t_data.Query2 do
begin
Close;
SQL.Clear;
SQL.Add('select * from tb_providercheck where ');
case Storagefield.ItemIndex of
0: SQL.Add('providername = :Value');
1: SQL.Add('checkman = :Value');
2: SQL.Add('checkid = :Value');
end;
SQL.Add(' and TimeDate >= :FromDate and Timedate < :ToDate');
Parameters.ParamByName('FromDate').Value := Trunc(Fromdate.DateTime);
Parameters.ParamByName('ToDate').Value := Trunc(ToDate.DateTime)+1;
Parameters.ParamByName('Value').Size := 100;
Parameters.ParamByName('Value