?? pzcx.pas
字號:
unit pzcx;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, Buttons, StdCtrls, ComCtrls, Grids, DBGrids, DB;
type
TForm7 = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
Label1: TLabel;
ComboBox1: TComboBox;
Panel3: TPanel;
Label2: TLabel;
DateTimePicker1: TDateTimePicker;
DateTimePicker2: TDateTimePicker;
Label3: TLabel;
CheckBox1: TCheckBox;
CheckBox2: TCheckBox;
Panel4: TPanel;
SpeedButton1: TSpeedButton;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
procedure FormShow(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form7: TForm7;
implementation
uses DataModal4;
{$R *.dfm}
procedure TForm7.FormShow(Sender: TObject);
begin
ComboBox1.Clear;
with Da.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('select Distinct 憑證號 from 憑證記賬表');
Open;
end;
if Da.ADOQuery1.RecordCount>0 then
while Not Da.ADOQuery1.Eof do
begin
ComboBox1.Items.Add(Da.ADOQuery1.FieldByName('憑證號').Value);
Da.ADOQuery1.Next;
end;
DataSource1.DataSet := Nil;
end;
procedure TForm7.SpeedButton1Click(Sender: TObject);
begin
if (CheckBox1.Checked = True)and(CheckBox2.Checked = True) then
begin
if DateTimepicker1.Date> DateTimePicker2.Date then
begin
Application.MessageBox('開始時(shí)間不能大于結(jié)束時(shí)間。','提示',64);
DataSource1.DataSet := Nil;
Exit;
end;
if Trim(ComboBox1.Text)='' then
begin
Application.MessageBox('請選擇憑證號.','提示',64);
ComboBox1.SetFocus;
Exit;
end;
with Da.ADOQuery2 do
begin
Close;
SQL.Clear;
SQL.Add('select * from 憑證記賬表 where 憑證號 in (select 憑證號 From 憑證表 where 日期>=:c and 日期<= :b and 憑證號 = :a )');
Parameters.ParamByName('a').Value := Trim(ComboBox1.Text);
Parameters.ParamByName('c').Value := Trunc(DateTimePicker1.Date)-2;
Parameters.ParamByName('b').Value := Trunc(DateTimePicker2.Date)-2+ 0.9998;
Open;
end;
if Da.ADOQuery2.RecordCount>0 then
DataSource1.DataSet := Da.ADOQuery2
else
begin
DataSource1.DataSet := Nil;
Application.MessageBox('沒有找到符合條件的記錄。','提示',64);
end;
end
else if (CheckBox2.Checked = True)and(CheckBox1.Checked = False)then
begin
with Da.ADOQuery2 do
begin
Close;
SQL.Clear;
SQL.Add('select * from 憑證記賬表 where 憑證號 =:a');
Parameters.ParamByName('a').Value := Trim(ComboBox1.Text);
Open;
end;
if Da.ADOQuery2.RecordCount>0 then
DataSource1.DataSet := Da.ADOQuery2
else
begin
DataSource1.DataSet := Nil;
Application.MessageBox('沒有找到符合條件的記錄。','提示',64);
end;
end
else if (CheckBox2.Checked = False)and(CheckBox1.Checked = true)then
begin
if DateTimepicker1.Date> DateTimePicker2.Date then
begin
Application.MessageBox('開始時(shí)間不能大于結(jié)束時(shí)間。','提示',64);
DataSource1.DataSet := Nil;
Exit;
end;
with Da.ADOQuery2 do
begin
Close;
SQL.Clear;
SQL.Add('select * from 憑證記賬表 where 憑證號 in (select 憑證號 From 憑證表 where 日期>=:c and 日期<= :b and 是否過賬 = ''是'' )');
Parameters.ParamByName('c').Value := Trunc(DateTimePicker1.Date)-2;
Parameters.ParamByName('b').Value := Trunc(DateTimePicker2.Date)-2+ 0.9998;
Open;
end;
if Da.ADOQuery2.RecordCount>0 then
DataSource1.DataSet := Da.ADOQuery2
else
begin
DataSource1.DataSet := Nil;
Application.MessageBox('沒有找到符合條件的記錄。','提示',64);
end;
end
else
Application.MessageBox('請選擇查詢條件。','提示',64);
end;
end.
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -