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

📄 mrp_qry_informaloblongmrp.pas

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

Interface

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

Type
  TFrm_Mrp_Qry_InformalOblongMrp = 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;
    AdoQry_HeadAssignedqty: TFloatField;
    procedure Act_LookExecute(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormDestroy(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure FormCreate(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_InformalOblongMrp: TFrm_Mrp_Qry_InformalOblongMrp;
   ItemCode,ItemName,Uom,ldtime,PmBatch,CurrentInv,Assignedqty,oncheckqty:string;

implementation

uses  Mrp_Qry_InformalOblongMrp_D;

{$R *.DFM}

{ TFrm_Mrp_Qry_InformalUpRightMrp }

procedure TFrm_Mrp_Qry_InformalOblongMrp.InitForm(
  AdOConnection: TAdOConnection; ShowExtendColumn: Boolean);
var sqltext0,sqltext1:string;
begin
  inherited;
  lbl_Mrprundate.Caption:=getValue('InformalRunMrpdate','MrpParam');
    //   freefields:='PmBatch,CurrentonhandInv,oncheckqty,';
    sqltext0:='select ItemCode,PmCode, min(releasedate) as releasedate  '
            +'   into #tmpioblgm                        '
            +'   from InformalMrpResult                    '
            +' where ordinal=3 '
            +'   and PmCode<>9 '
            +' group by ItemCode,PmCode   '
            +' select t1.ItemCode,t1.PmCode,t1.onhand,t1.Assignedqty,t1.oncheck,t1.releasedate,t1.ordinal '
            +' into #tmpioblgonhand    '
            +' from InformalMrpResult t1, #tmpioblgm t2             '
            +' where t1.ItemCode=t2.ItemCode            '
            +'  and  t1.releasedate=t2.releasedate      '
            +'  and  t1.ordinal=3                       '
            +'  and  t1.PmCode=t2.PmCode';

    sqltext1:=' Select distinct Item.ItemCode,Item.ItemName,Item.minqty,InformalMrpResult.PmCode,Item.Batchstrat,'+
              '         Itemflag=Item.ItemCode+'' ''+Item.ItemName,'+
             ' UomName=Uom.UomName,'+
             ' ldtime=case InformalMrpResult.PmCode '+
             '     when 0 then Item.mnldtime '+
             '     else  Item.purchldtime '+
             '   end,'+
             ' Item.Preparelt,'+
             ' Item.runlt,'+
             ' Item.Qclt,'+
             ' Item.PmBatch, '+
             ' #tmpioblgonhand.onhand-isnull(#tmpioblgonhand.Assignedqty,0) as CurrentonhandInv, '+
             ' Assignedqty=isnull(#tmpioblgonhand.Assignedqty,0), '+
             ' #tmpioblgonhand.oncheck as oncheckqty '+
            // ' Item.CurrentonhandInv '+
             ' into #tmpioblgtable '+
             ' From Item '+
             ' Join InformalMrpResult On Item.ItemCode=InformalMrpResult.ItemCode  and InformalMrpResult.ordinal=1'+
             ' Join #tmpioblgonhand On Item.ItemCode=#tmpioblgonhand.ItemCode and InformalMrpResult.PmCode=#tmpioblgonhand.PmCode'+
             ' left outer  join Uom on Item.UomCode=Uom.UomCode ';
selectfromsql:='select * from #tmpioblgtable';
    with AdoQry_Head do
      begin
        Close;
        sql.clear;
        sql.Add(sqltext0);
        Prepared;
        try
        execsql;
        except
        end;

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

        Close;
        sql.clear;
        sql.Add('select * from #tmpioblgtable Order by ItemCode');
        open;
      end;
end;


procedure TFrm_Mrp_Qry_InformalOblongMrp.Act_LookExecute(Sender: TObject);
begin
  inherited;
if AdoQry_Head.RecordCount=0 then exit;
 if Frm_Mrp_Qry_InformalOblongMrp_D=nil then
 begin
  Frm_Mrp_Qry_InformalOblongMrp_D:=TFrm_Mrp_Qry_InformalOblongMrp_D.Create(Self);
  Frm_Mrp_Qry_InformalOblongMrp_D.SetSysParam(userCode,ModuleCode,menuid,formatdatetime('yyyy.mm.dd',now));
  Frm_Mrp_Qry_InformalOblongMrp_D.ItemCode:=AdoQry_Head.fieldbyname('ItemCode').asstring;
  Frm_Mrp_Qry_InformalOblongMrp_D.InitForm(AdoQry_Head.Connection,True);
 end
 else Frm_Mrp_Qry_InformalOblongMrp_D.Show;
end;

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

end;

procedure TFrm_Mrp_Qry_InformalOblongMrp.FormDestroy(Sender: TObject);
begin
  inherited;
Frm_Mrp_Qry_InformalOblongMrp:=nil;
end;

function TFrm_Mrp_Qry_InformalOblongMrp.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;

procedure TFrm_Mrp_Qry_InformalOblongMrp.FormShow(Sender: TObject);
begin
  inherited;
//self.Windowstate:=wsmaximized;
end;

procedure TFrm_Mrp_Qry_InformalOblongMrp.FormCreate(Sender: TObject);
begin
  inherited;
self.Windowstate:=wsmaximized;
end;

end.

⌨️ 快捷键说明

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