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

📄 fjhfx.pas

📁 进销存开发系统
💻 PAS
字号:
unit Fjhfx;

interface

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

type
  TF_jhfx = class(TF_base)
    ToolBar1: TToolBar;
    SpeedButton1: TSpeedButton;
    ADOQuery1: TADOQuery;
    Panel1: TPanel;
    SpeedButton2: TSpeedButton;
    DateTimePicker1: TDateTimePicker;
    Label1: TLabel;
    DateTimePicker2: TDateTimePicker;
    StringGrid1: TStringGrid;
    ADOQuery2: TADOQuery;
    Label2: TLabel;
    ToolButton1: TToolButton;
    ToolButton2: TToolButton;
    ToolButton3: TToolButton;
    procedure SpeedButton1Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  F_jhfx: TF_jhfx;

implementation
  uses Fdm;
{$R *.dfm}

procedure TF_jhfx.SpeedButton1Click(Sender: TObject);
var
  gcol,grow,xh:integer;
begin
  inherited;
  Panel1.Visible:=not(Panel1.Visible);
  if Panel1.Visible=True then
    Exit;
  with Adoquery1 do   //查找进货表某段时间内的记录
  begin
    Close;
    SQL.Clear;
    SQL.Add('select tradecode,fullname,sum(qty),sum(qty*price) from tb_warehouse_detailed where billdate>=:a and billdate<=:b group by tradecode,fullname order by Tradecode');
    parameters.ParamByName('a').Value:=datetimepicker1.date;
    parameters.ParamByName('b').Value:=datetimepicker2.date;
    Open;
  end;
  if adoquery1.RecordCount=0 then
  begin
    Application.MessageBox('没有记录','提示',mb_ok);
    Exit;
  end;
  with Adoquery2 do    //查找进货退货表某段时间内的记录
  begin
    Close;
    SQL.Clear;
    SQL.Add('select tradecode,fullname,sum(qty) as qty,sum(qty*price) as price,tradecode from tb_rewarehouse_detailed where billdate>=:c and billdate<=:d  group by tradecode,fullname order by Tradecode');
    parameters.ParamByName('c').Value:=datetimepicker1.date;
    parameters.ParamByName('d').Value:=datetimepicker2.date;
    Open;
  end;
  with stringgrid1 do
  begin
    RowCount:=adoquery1.RecordCount+1;
    for grow:=1 to adoquery1.RecordCount+1 do
    begin
      cells[0,grow]:=inttostr(grow);
      for gcol:=1 to 4 do     //读取进货单的 商品编号,商品全称,商品数量,金额
      begin
          Cells[gcol,grow]:=adoquery1.Fields[gcol-1].Value;
      end;
      adoquery1.Next;
    end;
    adoquery1.First;
    for grow:=1 to adoquery1.RecordCount+1 do   //读取进货退货单的 商品数量,金额
    begin
      adoquery2.First;
      for gcol:=5 to 6 do
      begin
        for xh:=1 to adoquery2.RecordCount do
        begin
          if adoquery2.Fields[0].Value=adoquery1.Fields[0].Value then
            Cells[gcol,grow]:=adoquery2.Fields[gcol-3].Value
          else
          begin
            Cells[gcol,grow]:='0';
          end;
          adoquery2.Next;
        end;
        if adoquery2.RecordCount=0 then Cells[gcol,grow]:='0';
        Cells[8,grow]:=floattostr(strtofloat(Cells[3,grow])-strtofloat(Cells[5,grow]))
      end;
      if strtofloat(Cells[8,grow])<>0 then
        Cells[7,grow]:=format('%10.4f',[(strtofloat(Cells[4,grow])-strtofloat(Cells[6,grow]))/strtofloat(Cells[8,grow])])
      else
        Cells[7,grow]:='无商品';
      Cells[9,grow]:=format('%10.4f',[strtofloat(Cells[7,grow])*strtofloat(Cells[8,grow])]) ;
      adoquery1.Next;
    end;
  end;
end;

procedure TF_jhfx.FormShow(Sender: TObject);
begin
  inherited;
  datetimepicker1.Date:=now();
  datetimepicker2.Date:=now();
  with stringgrid1 do
  begin
    cells[1,0]:='商品编号';
    cells[2,0]:='商品全称';
    cells[3,0]:='进货数量';
    cells[4,0]:='进货金额';
    cells[5,0]:='进货退货数量';
    cells[6,0]:='进货退货金额';
    cells[7,0]:='均价';
    cells[8,0]:='商品余数';
    cells[9,0]:='总金额';
  end;
end;

procedure TF_jhfx.SpeedButton2Click(Sender: TObject);
begin
  inherited;
  close;
end;

procedure TF_jhfx.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
  inherited;
  if Application.MessageBox('是否退出?','提示',mb_yesno)=Id_no then
    Canclose:=False;
end;

end.

⌨️ 快捷键说明

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