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

📄 pm_qry_newinformalsspoinfo.pas

📁 一个MRPII系统源代码版本
💻 PAS
字号:
unit Pm_Qry_NewInformalSsPoInfo;

Interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Base_Qry, Menus, ExtPrintReport, Db, ActnList, AdODB, Grids, DBGridEh,
  StdCtrls, ExtCtrls, ComCtrls, ToolWin, DBCtrls, jpeg;

Type
  TFrm_Pm_Qry_NewInformalSsPoInfo = Class(TFrm_Base_Qry)
    AdoQry_MainItemCode: TStringField;
    AdoQry_MainItemName: TStringField;
    AdoQry_MainUomName: TStringField;
    AdoQry_MainPmBatch: TIntegerField;
    AdoQry_MainCurrentonhandInv: TFloatField;
    AdoQry_Mainssdate: TDateTimeField;
    AdoQry_Mainssqty: TFloatField;
    AdoQry_MainItemflag: TStringField;
    dbtxtItemflag: TDBText;
    Label1: TLabel;
    AdoQry_MainPreparelt: TIntegerField;
    AdoQry_Mainrunlt: TIntegerField;
    AdoQry_MainQclt: TIntegerField;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
  public
       procedure setconditionHint(lbl:Tlabel;cAp:string);
       procedure InitForm(AdOConnection:TAdOConnection;ShowExtendColumn:Boolean);Override;
    { Public declarations }
  end;

var
  Frm_Pm_Qry_NewInformalSsPoInfo: TFrm_Pm_Qry_NewInformalSsPoInfo;
    days:integer;
implementation

uses  Pm_Qry_InformalSsPoInfo_C,Sys_Global;

{$R *.DFM}

{ TFrm_Pm_Qry_InformalSsPoInfo_D }

procedure TFrm_Pm_Qry_NewInformalSsPoInfo.InitForm(
  AdOConnection: TAdOConnection; ShowExtendColumn: Boolean);
  var sqltext:string;
begin
  inherited;
    try
  with TFrm_Pm_Qry_InformalSsPoInfo_C.Create(self) do
    begin
     showmodal;
     if modalResult<>mrok then
        begin
        self.Close;
        exit;
        end;
     days:=strtoint(edtdays.text);
     end;
  finally
   Frm_Pm_Qry_InformalSsPoInfo_C.Free;
  end;
    sqltext:='  select top 0 ItemCode,ssdate,ssqty into #newtmpInformalres  from Informalss     '
             +'  select ItemCode,ssdate=releasedate,ssqty=onhand                                 '
             +'  into #newtmpInformalss                                                  '
             +'  from InformalMrpResult                                                      '
             +'  where (PmCode=1 or PmCode=2)                                   '
             +'    and ordinal=3                                        '
             +'   Order by ItemCode,ssdate                                    '
             +'  declAre @Count int,                                          '
             +'          @ItemCode varchAr(16),                               '
             +'          @ssdate   datetime,                                  '
             +'          @date     datetime,                                  '
             +'          @ssqty    float(8)                                   '
             +'   set rowCount 1                                              '
             +'  insert into #newtmpInformalres                                          '
             +'  select * from #newtmpInformalss                                         '
             +'  select @date=(select ssdate from #newtmpInformalres)                    '
             +'  delete from #newtmpInformalss                                           '
             +'  select @Count=(select Count(*) from #newtmpInformalss)                  '
             +'   while @Count>0                                              '
             +'     begin                                                     '
             +'       select @ItemCode=ItemCode from #newtmpInformalss                   '
             +'       select @ssdate=ssdate from #newtmpInformalss                       '
             +'       select @ssqty=ssqty from #newtmpInformalss                         '
             +'      if exists(select * from #newtmpInformalres where ItemCode=@ItemCode)'
             +'           begin                                               '
             +'              if dateDiff(dd,@date,@ssdate)<'+inttostr(days)
             +'                update #newtmpInformalres                                 '
             +'                set ssqty=ssqty+@ssqty                         '
             +'                where ItemCode=@ItemCode                       '
             +'                 and dateDiff(dd,ssdate,@ssdate)<'+inttostr(days)
             +'              else                                             '
             +'                 begin                                         '
             +'                  insert into #newtmpInformalres                          '
             +'                  select * from #newtmpInformalss                         '
             +'                  select @date=@ssdate                         '
             +'                 end                                           '
             +'          end                                                  '
             +'      else                                                     '
             +'        begin                                                  '
             +'          insert into #newtmpInformalres                                  '
             +'          select * from #newtmpInformalss                                 '
             +'          select @date=@ssdate                                 '
             +'        end                                                    '
             +'        delete from #newtmpInformalss                                     '
             +'        select @Count=@Count-1                                 '
             +'  end                                                          '
             +'     set rowCount 999999999                                    '
             +'     select      #newtmpInformalres.ItemCode,                             '
             +'                 Item.ItemName,        '
              +'                Itemflag=#newtmpInformalres.ItemCode+'' ''+Item.ItemName,                             '
             +'                 Uom.UomName,                                  '
             +'                 Item.Preparelt,                      '
             +'                 Item.runlt,                          '
             +'                 Item.Qclt,                           '
             +'                 Item.PmBatch,                                 '
             +'                 Item.CurrentonhandInv,                        '
             +'                 #newtmpInformalres.ssdate,                               '
             +'                 #newtmpInformalres.ssqty                                 '
             +'      into #newtmpInformal                                                '
             +'    from  #newtmpInformalres,Item(nolock),Uom(nolock)                     '
             +'     where #newtmpInformalres.ItemCode=Item.ItemCode                      '
             +'      and  Item.UomCode=Uom.UomCode                            '
             +'     Order by #newtmpInformalres.ItemCode,#newtmpInformalres.ssdate                  ';

 selectfromsql:='select * from #newtmpInformal';

  with AdoQry_Main do
    begin
      Close;
      sql.clear;
      sql.Add(sqltext);
      Prepared;
      try
      execsql;
      except
      end;

      Close;
      sql.clear;
      sql.Add('select * from #newtmpInformal');
      Prepared;
      try
      open;
      except
      end;

      if recordCount=0 then
       begin
        DispInfo('无模拟采购建议相关数据!',3);
        self.Close;
       end;
    end;
  end;


procedure TFrm_Pm_Qry_NewInformalSsPoInfo.setconditionHint(lbl: Tlabel;
  cAp: string);
begin
   lbl.Caption:=cAp;
end;

procedure TFrm_Pm_Qry_NewInformalSsPoInfo.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
    with AdoQry_tmp do
      begin
          Close;
          sql.clear;
          sql.Add('drop table #newtmpInformalss,#newtmpInformalres,#newtmpInformal');
          try
          execsql;
          except
          end;
      end;

  inherited;

end;

procedure TFrm_Pm_Qry_NewInformalSsPoInfo.FormDestroy(Sender: TObject);
begin
  inherited;
 Frm_Pm_Qry_NewInformalSsPoInfo:=nil;
end;

end.

⌨️ 快捷键说明

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