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

📄 fkcmx.pas

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

interface

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

type
  TF_kcmx = class(TF_base)
    Panel1: TPanel;
    Label1: TLabel;
    StringGrid1: TStringGrid;
    Panel2: TPanel;
    ADOQuery1: TADOQuery;
    ADOQuery2: TADOQuery;
    StatusBar1: TStatusBar;
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  F_kcmx: TF_kcmx;

implementation
  uses Fkczk,Fdm,Fzct,Fkcbd;
{$R *.dfm}

procedure TF_kcmx.FormShow(Sender: TObject);
var
  sp:string;
  grow,gcol,xhone,xhtwo:integer;
  rksl,cksl:real;
begin
  inherited;
  rksl:=0;     //某日期内商品入库量
  cksl:=0;     //某日期内商品出库量
  with stringgrid1 do
  begin
    cells[0,0]:='行号';
    cells[1,0]:='日期';
    cells[2,0]:='单据编号';
    cells[3,0]:='说明';
    cells[4,0]:='入库量';
    cells[5,0]:='出库量';
  end;
  sp:=F_dm.ADOQuery1.Fields[1].AsString;   //sp为商品全名
  Panel2.Caption:=sp;
  with Adoquery1 do   //在往来明细表中查找进货,进货退货,销售,销售退货记录
  begin
    Close;
    SQL.Clear;
    SQL.Add('select billcode from tb_currentaccount where  billdate between :one and :two and (billcode like '+'''%'+'jh'+'%'''+ 'or billcode like'+'''%'+'xs'+'%'''+') order by billdate');
    if F_zct.mx=1 then            //库存状况窗体中调用本窗体
    begin
      Parameters.ParamByName('one').Value:=F_kczk.DateTimePicker1.Date;
      parameters.ParamByName('two').Value:=F_kczk.DateTimePicker2.Date;
    end;
    if F_zct.mx=2 then            //进销存变动窗体中调用本窗体
    begin
      Parameters.ParamByName('one').Value:=F_kcbd.DateTimePicker1.Date;
      parameters.ParamByName('two').Value:=F_kcbd.DateTimePicker2.Date;
    end;
    Open;
  end;
  Adoquery1.First;    //记录指针移到第一条记录
  grow:=1;
  for xhone:=1 to Adoquery1.RecordCount do
  begin
    with Adoquery2 do  //在进货明细表中查找符合条件的记录
    begin
      Close;
      SQL.Clear;
      SQL.Add('select a.billdate,a.billcode,a.fullname,a.qty,b.units,b.billcode from tb_warehouse_detailed a,tb_warehouse_main b where a.billcode=b.billcode and a.billcode=:bh and a.fullname=:fn');
      parameters.ParamByName('bh').Value:=adoquery1.Fields[0].Value;
      parameters.ParamByName('fn').Value:=sp;
      Open;
    end;
      for xhtwo:=grow to grow+Adoquery2.RecordCount-1 do
      begin
        for gcol:=1 to 4 do
        begin
          with stringgrid1 do
          begin
            if gcol<=2 then
              cells[gcol,xhtwo]:=Adoquery2.Fields[gcol-1].Value;
            if gcol=3 then
              cells[3,xhtwo]:='进货:【'+Adoquery2.Fields[4].Value+'】';
            if gcol=4 then
            begin
              cells[4,xhtwo]:=adoquery2.Fields[3].Value;
              rksl:=rksl+adoquery2.Fields[3].Value;
            end;
          end;
        end;
        Adoquery2.Next;
      end;
      grow:=grow+adoquery2.RecordCount;
    ////////////////////////////////////////////////
    with Adoquery2 do  //在进货退货明细表中查找符合条件的记录
    begin
      Close;
      SQL.Clear;
      SQL.Add('select a.billdate,a.billcode,a.fullname,a.qty,b.units,b.billcode from tb_rewarehouse_detailed a,tb_rewarehouse_main b where a.billcode=b.billcode and a.billcode=:bh and a.fullname=:fn');
      parameters.ParamByName('bh').Value:=adoquery1.Fields[0].Value;
      parameters.ParamByName('fn').Value:=sp;
      Open;
    end;
      for xhtwo:=grow to grow+Adoquery2.RecordCount-1 do
      begin
        for gcol:=1 to 4 do
        begin
          with stringgrid1 do
          begin
            if gcol<=2 then
              cells[gcol,xhtwo]:=Adoquery2.Fields[gcol-1].Value;
            if gcol=3 then
              cells[3,xhtwo]:='进货退货:【'+Adoquery2.Fields[4].Value+'】';
            if gcol=4 then
            begin
              cells[5,xhtwo]:=adoquery2.Fields[3].Value;
              cksl:=cksl+adoquery2.Fields[3].Value;
            end;
          end;
        end;
        Adoquery2.Next;
      end;
      grow:=grow+adoquery2.RecordCount;
    //////////////////////////////////////////////////////
    with Adoquery2 do  //在销售明细表中查找符合条件的记录
    begin
      Close;
      SQL.Clear;
      SQL.Add('select a.billdate,a.billcode,a.fullname,a.qty,b.units,b.billcode from tb_sell_detailed a,tb_sell_main b where a.billcode=b.billcode and  a.billcode=:bh and a.fullname=:fn');
      parameters.ParamByName('bh').Value:=adoquery1.Fields[0].Value;
      parameters.ParamByName('fn').Value:=sp;
      Open;
    end;
      for xhtwo:=grow to grow+Adoquery2.RecordCount-1 do
      begin
        for gcol:=1 to 4 do
        begin
          with stringgrid1 do
          begin
            if gcol<=2 then
              cells[gcol,xhtwo]:=Adoquery2.Fields[gcol-1].Value;
            if gcol=3 then
              cells[3,xhtwo]:='销售:【'+Adoquery2.Fields[4].Value+'】';
            if gcol=4 then
            begin
              cells[5,xhtwo]:=adoquery2.Fields[3].Value;
              cksl:=cksl+adoquery2.Fields[3].Value;
            end;
          end;
        end;
        Adoquery2.Next;
      end;
      grow:=grow+adoquery2.RecordCount;
    //////////////////////////////////////////////////////
    with Adoquery2 do  //在销售退货明细表中查找符合条件的记录
    begin
      Close;
      SQL.Clear;
      SQL.Add('select a.billdate,a.billcode,a.fullname,a.qty,b.units,b.billcode from tb_resell_detailed a,tb_resell_main b where a.billcode=b.billcode and a.billcode=:bh and a.fullname=:fn');
      parameters.ParamByName('bh').Value:=adoquery1.Fields[0].Value;
      parameters.ParamByName('fn').Value:=sp;
      Open;
    end;
      for xhtwo:=grow to grow+Adoquery2.RecordCount-1 do
      begin
        for gcol:=1 to 4 do
        begin
          with stringgrid1 do
          begin
            if gcol<=2 then
              cells[gcol,xhtwo]:=Adoquery2.Fields[gcol-1].Value;
            if gcol=3 then
              cells[3,xhtwo]:='销售退货:【'+Adoquery2.Fields[4].Value+'】';
            if gcol=4 then
            begin
              cells[4,xhtwo]:=adoquery2.Fields[3].Value;
              rksl:=rksl+adoquery2.Fields[3].Value;
            end;
          end;
        end;
        Adoquery2.Next;
      end;
      grow:=grow+adoquery2.RecordCount;
    Adoquery1.Next;
  end;
  for  xhtwo:=1 to grow do
  begin
    stringgrid1.cells[0,xhtwo]:=inttostr(xhtwo);       //记录号
  end;
  stringgrid1.RowCount:=grow+1;
  
  statusbar1.Panels[1].Text:='商品入库数量:'+Floattostr(rksl);
  statusbar1.Panels[2].Text:='商品出库数量:'+Floattostr(cksl);
end;

end.

⌨️ 快捷键说明

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