u_outdetailqry.pas

来自「河南师范大学餐饮进销存软件,只要控制库存的数据。」· PAS 代码 · 共 131 行

PAS
131
字号
unit u_OutDetailQRY;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, DB, Grids, DBGrids, ADODB, StdCtrls, ComCtrls;

type
  TfrmOutDetailQRY = class(TForm)
    Panel1: TPanel;
    qry: TADOQuery;
    DBGrid1: TDBGrid;
    DataSource1: TDataSource;
    Label1: TLabel;
    cmbCus: TComboBox;
    edtOutBH: TLabeledEdit;
    Label2: TLabel;
    dtpDate: TDateTimePicker;
    qryCus: TADOQuery;
    Panel2: TPanel;
    Label3: TLabel;
    edtTotalMon: TEdit;
    btnPrint: TButton;
    procedure FormShow(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure cmbCusChange(Sender: TObject);
    procedure edtOutBHChange(Sender: TObject);
    procedure dtpDateChange(Sender: TObject);
    procedure btnPrintClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmOutDetailQRY: TfrmOutDetailQRY;

implementation

uses u_DataCtrl, u_OutDetailRep;

{$R *.dfm}

procedure TfrmOutDetailQRY.FormShow(Sender: TObject);
begin
  qryCus.Active := True;
  while not(qryCus.Eof) do
  begin
    cmbCus.Items.Add(qryCus.FieldValues['CusSName']);
    qryCus.Next;
  end;
  edtTotalMon.Text := '0.0' ;
  dtpDate.Date := Date();
end;

procedure TfrmOutDetailQRY.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  cmbCus.Clear;
  edtOutBH.Clear;
  Action := CaFree ;
end;

procedure TfrmOutDetailQRY.cmbCusChange(Sender: TObject);
var
  TotalMon : real ;
begin
  qry.Close;
  qry.SQL.Clear;
  qry.SQL.Text := 'exec psp_GoodsOutDetail '+QuotedStr(cmbCus.Text)+','+QuotedStr(edtOutBH.Text)+','+QuotedStr(FormatDateTime('yyyy-mm-dd',dtpDate.Date));
  qry.Open;
  TotalMon := 0.0 ;
  while not qry.Eof do
    begin
      TotalMon := TotalMon + qry.FieldValues['GoodsTotal'];
      qry.Next;
    end;
  edtTotalMon.Text := FloatToStr(TotalMon) ;
end;

procedure TfrmOutDetailQRY.edtOutBHChange(Sender: TObject);
var
  TotalMon : real ;
begin
  qry.Close;
  qry.SQL.Clear;
  qry.SQL.Text := 'exec psp_GoodsOutDetail '+QuotedStr(cmbCus.Text)+','+QuotedStr(edtOutBH.Text)+','+QuotedStr(FormatDateTime('yyyy-mm-dd',dtpDate.Date));
  qry.Open;
  TotalMon := 0.0 ;
  while not qry.Eof do
    begin
      TotalMon := TotalMon + qry.FieldValues['GoodsTotal'];
      qry.Next;
    end;
  edtTotalMon.Text := FloatToStr(TotalMon) ;
end;

procedure TfrmOutDetailQRY.dtpDateChange(Sender: TObject);
var
  TotalMon : real ;
begin
  qry.Close;
  qry.SQL.Clear;
  qry.SQL.Text := 'exec psp_GoodsOutDetail '+QuotedStr(cmbCus.Text)+','+QuotedStr(edtOutBH.Text)+','+QuotedStr(FormatDateTime('yyyy-mm-dd',dtpDate.Date));
  qry.Open;
  TotalMon := 0.0 ;
  while not qry.Eof do
    begin
      TotalMon := TotalMon + qry.FieldValues['GoodsTotal'];
      qry.Next;
    end;
  edtTotalMon.Text := FloatToStr(TotalMon) ;
end;


procedure TfrmOutDetailQRY.btnPrintClick(Sender: TObject);
begin
  if Qry.Active=true then
  if Qry.RecordCount>0 then
    begin
      frmOutDetailRep.edtCus.Caption := cmbCus.Text ;
      frmOutDetailRep.edtDate.Caption := FormatDateTime('yyyy-mm-dd',dtpdate.Date);
      frmOutDetailRep.edtOutBH.Caption := edtOutBH.Text ;
      frmOutDetailRep.OutDetailReport.Preview;
    end;
end;

end.

⌨️ 快捷键说明

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