⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pzcx.pas

📁 凭证管理系统的制作
💻 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('开始时间不能大于结束时间。','提示',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('开始时间不能大于结束时间。','提示',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.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -