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

📄 spbybb.pas

📁 这是用Delphi编写的中小企业管理系统
💻 PAS
字号:
unit spbybb;

interface

uses            
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, spbsbb, DB, RpDefine, RpBase, RpSystem, ComCtrls, StdCtrls,
  Grids, DBGrids, Buttons, ExtCtrls,main;

type
  Tf_spbybb = class(Tf_spbsbb)
    procedure zdChange(Sender: TObject); override;
    procedure cxClick(Sender: TObject); Override;
    procedure FormCreate(Sender: TObject);override;
    procedure ylClick(Sender: TObject);override;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  f_spbybb: Tf_spbybb;

implementation

uses DataModal,spbsdysz;

{$R *.dfm}

procedure Tf_spbybb.zdChange(Sender: TObject);
begin
 if Trim(zd.Text)<>'' then
  begin
    zhi.Clear;
    Case zd.ItemIndex of
      0: TempField := 'byph';
      1: TempField := 'spdm';
      2: TempField := 'spmc';
      3: TempField := 'kcmc';
    end;
    if TempField<>'spmc' then
    begin
      with Data.Query1 do
      begin
        Close;
        SQL.Clear;
        SQL.Add('select distinct '+ TempField + ' From t_bymx');
        Open;
      end;
    end
    else
    begin
      with Data.Query1 do
      begin
        Close;
        SQL.Clear;
        SQL.Add('select distinct '+ TempField + ' From t_spjcxx');
        Open;
      end;
    end;
    while Not Data.Query1.Eof do
    begin
      zhi.Items.Add(Trim(Data.Query1.Fields[0].AsString));
      Data.Query1.Next;
    end;
  end;

end;

procedure Tf_spbybb.cxClick(Sender: TObject);
begin
  if check1.Checked = True then
  begin
    if (Trim(zd.Text)<>'')and(Trim(zhi.Text)<>'') then
    begin
      if check2.Checked = False then
      begin
        with Data.Query2 do
        begin
          Close;
          SQL.Clear;
          if TempField <>'spmc' then
            SQL.Add('select aa.byph,aa.kcmc,aa.spdm,bb.spmc,aa.sl,aa.cbj,aa.je,aa.bzq from t_bymx aa inner join t_spjcxx bb on aa.spdm = bb.spdm and aa.'+TempField + ' =:a')
          else
            SQL.Add('select aa.byph,aa.kcmc,aa.spdm,bb.spmc,aa.sl,aa.cbj,aa.je,aa.bzq from t_bymx aa inner join t_spjcxx bb on aa.spdm = bb.spdm and bb.'+TempField + ' =:a');
          ParamByName('a').AsString := Trim(zhi.Text);
          Open;
        end;
        if Data.Query2.RecordCount>0 then
        begin
          DataSource1.DataSet := Data.Query2;
          dy.Enabled := True;
        end
        else
        begin
          DataSource1.DataSet := Nil;
          dy.Enabled := False;
          Application.MessageBox('没有符合条件的记录.','提示',64);
        end;
      end
      else
      begin
        if zzsj.DateTime<qssj.DateTime then
        begin
          Application.MessageBox('起始时间不能大于终止时间.','提示',64);
          Exit;
        end;
        with Data.Query2 do
        begin
          Close;
          SQL.Clear;
          if TempField <>'spmc' then
            SQL.Add('select a.byph,a.kcmc,a.spdm,b.spmc,a.sl,a.cbj,a.je,a.bzq from t_bymx a inner join t_spjcxx b on a.spdm = b.spdm and a.'+TempField + ' =:aa and a.byph in (select byph from t_bycl where sj >=:bb and sj<:cc )')
          else
            SQL.Add('select a.byph,a.kcmc,a.spdm,b.spmc,a.sl,a.cbj,a.je,a.bzq from t_bymx a inner join t_spjcxx b on a.spdm = b.spdm and b.'+TempField + ' =:aa and a.byph in (select byph from t_bycl where sj >=:bb and sj<:cc )');
          ParamByName('aa').AsString := Trim(zhi.Text);
          ParamByName('bb').AsDate := Trunc(qssj.DateTime)-2;
          ParamByName('cc').AsDate := Trunc(zzsj.DateTime)-2+1;
          Open;
        end;
        if Data.Query2.RecordCount>0 then
        begin
          DataSource1.DataSet := Data.Query2;
          dy.Enabled := True;
        end
        else
        begin
          DataSource1.DataSet := Nil;
          dy.Enabled := False;
          Application.MessageBox('没有符合条件的记录.','提示',64);
        end;
      end;
    end;
  end
  else if check2.Checked = True then
  begin
    if zzsj.DateTime<qssj.DateTime then
    begin
      Application.MessageBox('起始时间不能大于终止时间.','提示',64);
      Exit;
    end;
    with Data.Query2 do
    begin
      Close;
      SQL.Clear;
      SQL.Add('select aa.byph,aa.kcmc,aa.spdm,bb.spmc,aa.sl,aa.cbj,aa.je,aa.bzq from t_bymx aa inner join t_spjcxx bb on aa.byph in (select byph from t_bycl where sj>= :b and sj<:c)');
      ParamByName('b').AsDate := Trunc(qssj.DateTime)-2;
      ParamByName('c').AsDate := Trunc(zzsj.DateTime)-2+1;
      Open;
    end;
    if Data.Query2.RecordCount>0 then
    begin
      DataSource1.DataSet := Data.Query2;
      dy.Enabled := True;
    end
    else
    begin
      DataSource1.DataSet := Nil;
      dy.Enabled := False;
      Application.MessageBox('没有符合条件的记录.','提示',64);
    end;
  end
  else
    Application.MessageBox('请设置查询条件.','提示',64);

end;

procedure Tf_spbybb.FormCreate(Sender: TObject);
begin
  inherited;
  bbTitle := '商品报溢报表';
  AZdmc[0]:='报溢票号';
end;

procedure Tf_spbybb.ylClick(Sender: TObject);
begin
  inherited;
  f_spbsdysz.Label18.Caption := '报溢票号';
end;

end.

⌨️ 快捷键说明

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