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

📄 mrp_qry_newinformaloblongmrp.pas

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

Interface

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

Type
  TFrm_Mrp_Qry_NewInformalOblongMrp = Class(TFrm_Base_Entry_Head)
    AdoQry_HeadItemCode: TStringField;
    AdoQry_HeadItemName: TStringField;
    AdoQry_HeadUomName: TStringField;
    AdoQry_Headldtime: TFloatField;
    AdoQry_HeadCurrentonhandInv: TFloatField;
    AdoQry_HeadItemflag: TStringField;
    AdoQry_Headoncheckqty: TFloatField;
    AdoQry_Headminqty: TFloatField;
    AdoQry_HeadPmCode: TIntegerField;
    AdoQry_HeadBatchstrat: TIntegerField;
    Label8: TLabel;
    lbl_Mrprundate: TLabel;
    AdoQry_HeadPreparelt: TIntegerField;
    AdoQry_Headrunlt: TIntegerField;
    AdoQry_HeadQclt: TIntegerField;
    AdoQry_HeadPmBatch: TIntegerField;
    procedure Act_LookExecute(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormDestroy(Sender: TObject);
  private
  function getValue(Code:string;tableName:string):variant;
    { Private declarations }
  public
    procedure InitForm(AdOConnection:TAdOConnection;ShowExtendColumn:Boolean);Override;
    { Public declarations }
  end;

var
  Frm_Mrp_Qry_NewInformalOblongMrp: TFrm_Mrp_Qry_NewInformalOblongMrp;
  // ItemCode,ItemName,Uom,ldtime,PmBatch,CurrentInv,oncheckqty:string;
implementation

uses  Mrp_Qry_NewInformalOblongMrp_D;

{$R *.DFM}

{ TFrm_Mrp_Qry_UpRightMrp }

procedure TFrm_Mrp_Qry_NewInformalOblongMrp.InitForm(AdOConnection: TAdOConnection;
  ShowExtendColumn: Boolean);
var sqltext0,sqltext00,sqltext1:string;
begin
  inherited;
    lbl_Mrprundate.Caption:=getValue('InformalRunMrpdate','MrpParam');
    // freefields:='PmBatch,CurrentonhandInv,oncheckqty,';
      {sqltext0:='select distinct ItemCode,PmCode, min(releasedate) as releasedate  '
            +'   into #tmpoblgm                        '
            +'   from MrpResult                    '
            +' where ordinal=0 '
            +'   and PmCode<>9 '
            +'   group by ItemCode,PmCode   '
            +' select t1.ItemCode,t1.PmCode,t1.onhand,t1.oncheck,t1.Assignedqty,t1.releasedate,t1.ordinal '
            +' into #tmpoblgonhand    '
            +' from MrpResult t1, #tmpoblgm t2             '
            +' where t1.ItemCode=t2.ItemCode            '
            +'  and  t1.releasedate=t2.releasedate      '
            +'  and  t1.ordinal=0                       '
            +'  and  t1.PmCode=t2.PmCode'; }
    sqltext0:='select ItemCode,PmCode,onhand,releasedate,ordinal into #tmpioblgonhand from InformalMrpResult where ordinal=0';
    sqltext00:='select ItemCode,PmCode,onhand,releasedate,ordinal into #tmpioblgoncheck from InformalMrpResult where ordinal=1';

    sqltext1:=' declAre @VisualManuObject Integer ' 
             +' Select  @VisualManuObject=MrpParamValueN  '
             +'    From  MrpParam '
             +'   Where   MrpParamCode=''VisualManuObject'''
             +' Select distinct Item.ItemCode,Item.ItemName,Item.minqty,Item.PmCode,Item.Batchstrat,'+
              ' Itemflag=Item.ItemCode+'' ''+Item.ItemName,'+
             ' UomName=Uom.UomName,'+
             ' ldtime=case Item.PmCode '+
             '     when 0 then Item.mnldtime '+
             '     else Item.purchldtime '+
             '   end,'+
             ' Item.Preparelt,'+
             ' Item.runlt,'+
             ' Item.Qclt,'+
             ' Item.PmBatch, '+
             ' case when @VisualManuObject=1 and IsNUll(Mps.MpsStatus,100)=3 then 0.0 '+
             '      else  Item.CurrentonhandInv ' 
             +' end as CurrentonhandInv, '+
            // ' Assignedqty=isnull(#tmpoblgonhand.Assignedqty,0), '+
             ' case when @VisualManuObject=1 and IsNUll(Mps.MpsStatus,100)=3 then 0.0 '+
             '      else Item.CurrentonCheckInv '+
             '   end as oncheckqty '+
             //' Item.CurrentonhandInv '+
             ' into #tmpioblgItemResult'+
             ' From Item '+
             ' left join Mps On Item.ItemCode=Mps.ItemCode ' +
             ' Join #tmpioblgonhand On Item.ItemCode=#tmpioblgonhand.ItemCode '+
             ' Join #tmpioblgoncheck On Item.ItemCode=#tmpioblgoncheck.ItemCode '+
               ' left outer join Uom on Item.UomCode=Uom.UomCode ';
    selectfromsql:='select * from #tmpioblgItemResult';
    with AdoQry_Head do
      begin
        Close;
        sql.clear;
        sql.Add(sqltext0);
        Prepared;
        try
        execsql;
        except
        end;

        Close;
        sql.clear;
        sql.Add(sqltext00);
        Prepared;
        try
        execsql;
        except
        end;

        Close;
        sql.clear;
        sql.Add(sqltext1);
        Prepared;
        try
        execsql;
        except
        end;

        Close;
        sql.clear;
        sql.Add('select * from #tmpioblgItemResult Order by ItemCode');
        open;
      end;
end;
       
procedure TFrm_Mrp_Qry_NewInformalOblongMrp.Act_LookExecute(Sender: TObject);
begin
 // inherited;
 if AdoQry_Head.RecordCount=0 then exit;     
 if Frm_Mrp_Qry_NewInformalOblongMrp_D=nil then
 begin
   Frm_Mrp_Qry_NewInformalOblongMrp_D:=TFrm_Mrp_Qry_NewInformalOblongMrp_D.Create(Self);
   Frm_Mrp_Qry_NewInformalOblongMrp_D.SetSysParam(userCode,ModuleCode,menuid,formatdatetime('yyyy.mm.dd',now));
   Frm_Mrp_Qry_NewInformalOblongMrp_D.ItemCode:=AdoQry_Head.fieldbyname('ItemCode').asstring;
   Frm_Mrp_Qry_NewInformalOblongMrp_D.mRunMrp:=1;
   Frm_Mrp_Qry_NewInformalOblongMrp_D.InitForm(AdoQry_Head.Connection,True);
 end
 else Frm_Mrp_Qry_NewInformalOblongMrp_D.Show;
end;

procedure TFrm_Mrp_Qry_NewInformalOblongMrp.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
with AdoQry_tmp do
  begin
    Close;
    sql.clear;
    sql.Add('drop table #tmpioblgItemResult,#tmpioblgoncheck,#tmpioblgonhand');
    try
    execsql;
    except
    end;
  end;

  inherited;

end;

procedure TFrm_Mrp_Qry_NewInformalOblongMrp.FormDestroy(Sender: TObject);
begin
  inherited;
  Frm_Mrp_Qry_NewInformalOblongMrp:=nil;
end;

function TFrm_Mrp_Qry_NewInformalOblongMrp.getValue(Code,
  tableName: string): variant;
var tmpAdoQry:TAdoQuery;
begin
 tmpAdoQry:=TAdoQuery.Create(Application);
 tmpAdoQry.EnableBCD:=False;
 try
   with tmpAdoQry do
     begin
      Connection:=dbconnect;
       Close;
       sql.clear;
       sql.Text:='select MrpParamValuec from '+tableName+' where MrpParamCode='+quotedstr(Code);
       open;
       try
       Result:=fieldbyname('MrpParamValuec').asstring;
       except
       Result:='';
       end;
     end;
 finally
   tmpAdoQry.Free;
 end;
end;

end.

⌨️ 快捷键说明

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