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

📄 bas_qry_bomchange.pas

📁 一个MRPII系统源代码版本
💻 PAS
📖 第 1 页 / 共 2 页
字号:
}
     //     ExecuteSql(AdoQry_Tmp,'select * Into ReMnItemList from #ReMnItemList',1);
          sqltext:='update mnItemList'
                  + '   set BilllineremArk=#remnItemList.BilllineremArk, '
                  +'        BomRemArk = #remnItemList.BomRemArk ,       '
                  + '        DeptCode =#remnItemList.DeptCode,          '
                  + '        alterNative =#remnItemList.alterNative,    '
                  + '        Currentqty  =#remnItemList.Currentqty,     '
                  + '        Bomqty      =#remnItemList.Bomqty,         '
                  + '        BomScrAp_Percent=#remnItemList.BomScrAp_Percent, '
                  + '        moCtrlqty   =#remnItemList.moCtrlqty,          '
                  + '        moRequestqty=#remnItemList.moRequestqty,       '
                  + '        bfrealqty   =#remnItemList.bfrealqty '
                  + '   from mnItemList,#tmPmnItemList,#remnItemList '
                  + '  where mnItemList.ItemListid=#tmPmnItemList.ItemListid '
                  + '    and #tmPmnItemList.itedir=#remnItemList.itedir '
                  + '    and #tmPmnItemList.mono=#remnItemList.mono  '
                  + '    and #tmPmnItemList.MoLineno=#remnItemList.MoLineno '
                  + '    and #tmPmnItemList.ItemCode=#remnItemList.ItemCode ';
          Executesql(AdoQry_tmp,sqltext,1)            ;

          sqltext:='delete from mnItemList '
                  +' where exists(select * from #tmPmnItemList where mnItemList.ItemListid=#tmPmnItemList.ItemListid '
                  +'                 and not exists(select * from #remnItemList where #tmPmnItemList.itedir=#remnItemList.itedir and #tmPmnItemList.ItemCode=#remnItemList.ItemCode)) '
                  +'  and mono= '+quotedstr(AdoQry_Mo.fieldbyname('mono').asstring)
                  +'  and MoLineno= '+inttostr(AdoQry_Mo.fieldbyname('MoLineno').asinteger)
                  +'  and MoRealqty= 0  ';
          Executesql(AdoQry_tmp,sqltext,1)            ;

          sqltext:=' Insert MnItemList '
                  +' (MONo,MoLineNo,BomRemArk, ItemCode,Ite_ItemCode,MoRealQty,'
                  +' MORequestQty,MOCtrlQty,BomQty,BomScrAp_Percent,DeptCode,'
                  +' alterNative,Parentid)'
                  +' select distinct #remnItemList.mono,#remnItemList.MoLineno,#remnItemList.BomremArk,#remnItemList.ItemCode,#remnItemList.ite_ItemCode,#remnItemList.MoRealqty, '
                  +'        #remnItemList.moRequestqty,#remnItemList.moCtrlqty,#remnItemList.Bomqty,#remnItemList.BomScrAp_Percent, '
                  +'        #remnItemList.DeptCode,#remnItemList.alterNative,#ReMnItemList.Parentid   '
                  +'   from #remnItemList '
                  +' where #remnItemList.itedir+'',''+#remnItemList.ItemCode not in (select IsNull(itedir+'',''+ItemCode,'''') from #tmPmnItemList) '
                  +'   and #remnItemList.Parentid=0  ';
          Executesql(AdoQry_tmp,sqltext,1)             ;

          sqltext:=' select * from #remnItemList '
                  +'  where itedir+'',''+ItemCode not in (select IsNull(itedir,'''')+'',''+ItemCode from #tmPmnItemList) '
                  +'    and Parentid<>0 '
                  +'  Order  by ItemListid ';
          Executesql(AdoQry,sqltext,0)            ;
          while not AdoQry.Eof do
            begin
              sqltext:=' Insert MnItemList '
                       +' (MONo,MoLineNo,BomRemArk,ItemCode,Ite_ItemCode,MoRealQty,'
                       +' MORequestQty,MOCtrlQty,BomQty,BomScrAp_Percent,DeptCode,'
                       +' alterNative,Parentid)'
                       +' select distinct #remnItemList.mono,#remnItemList.MoLineno,#remnItemList.BomremArk,#remnItemList.ItemCode,#remnItemList.ite_ItemCode,#remnItemList.MoRealqty, '
                       +'        #remnItemList.moRequestqty,#remnItemList.moCtrlqty,#remnItemList.Bomqty,#remnItemList.BomScrAp_Percent, '
                       +'        #remnItemList.DeptCode,#remnItemList.alterNative,IsNull(#tmPmnItemList.ItemListid,0)   '
                       +'   from #remnItemList '
                       +'   left join #TmPmnItemList on  ( #remnItemList.ite_ItemCode=#tmPmnItemList.ItemCode '
                       +'   and ((#remnItemList.itedir=#tmPmnItemList.itedir ) or (#remnItemList.itedir=#tmPmnItemList.itedir+'',''+#tmPmnItemList.ItemCode)))'
                       +'   where #remnItemList.ItemListid='+inttostr(AdoQry.fieldbyname('ItemListid').asinteger);
              Executesql(AdoQry_tmp,sqltext,1)             ;
              AdoQry.Next;
            end;
            sqltext:='update MoLine'
                    +'  set confirmtime=getdate() '
                    +' where mono='+quotedstr(AdoQry_Mo.fieldbyname('mono').asstring)
                    +'   and MoLineno='+inttostr(AdoQry_Mo.fieldbyname('MoLineno').asinteger);
            Executesql(AdoQry_tmp,sqltext,1) ;
        end;
        if AdoQry_Mo.fieldbyname('OrderType').AsInteger=1 then
        begin
          sqltext:='select * into #topItemList from opItemList'
                  +' where pono='+quotedstr(AdoQry_Mo.fieldbyname('mono').asstring)
                  +'   and polineno='+inttostr(AdoQry_Mo.fieldbyname('MoLineno').asinteger);
          Executesql(AdoQry_tmp,sqltext,1);
          sqltext:='delete from opItemList'
                  +' where pono='+quotedstr(AdoQry_Mo.fieldbyname('mono').asstring)
                  +'   and polineno='+inttostr(AdoQry_Mo.fieldbyname('MoLineno').asinteger);
    //              +'   and porealqty=0 ';
          Executesql(AdoQry_tmp,sqltext,1)                  ;

{          AutoBuildopListOrder(AdoQry_Mo.Connection,AdoQry_Mo.fieldbyname('mono').asstring,Trim(getCode(AdoQry_Mo.fieldbyname('ItemCode').AsString)),IntToStr(AdoQry_Mo.fieldbyname('MoLineNo').AsInteger),
             'Add','Po',AdoQry_Mo.fieldbyname('MoQty').Asfloat) ;  //自动产生领料单
}
          IF Not NewAutoBuildopListOrder(DbConnect,Trim(AdoQry_Mo.fieldbyname('MoNo').AsString),IntToStr(AdoQry_Mo.fieldbyname('MoLineNo').AsInteger),Trim(getCode(AdoQry_Mo.fieldbyname('ItemCode').AsString)),
             0,AdoQry_Mo.fieldbyname('MoQty').Asfloat) Then abort; //自动产生领料单

          sqltext:='update opItemList'
                  +'   set opItemList.porealqty=#topItemList.porealqty '
                  +'  from opItemList,#topItemList '
                  +' where opItemList.pono=#topItemList.pono '
                  +'   and opItemList.polineno=#topItemList.polineno '
                  +'   and opItemList.ItemCode=#topItemList.ItemCode '
                  +'   and opItemList.ite_ItemCode=#topItemList.ite_ItemCode '
                  +'   and opItemList.pono='+quotedstr(AdoQry_Mo.fieldbyname('mono').asstring)
                  +'   and opItemList.polineno='+inttostr(AdoQry_Mo.fieldbyname('MoLineno').asinteger);
          Executesql(AdoQry_tmp,sqltext,1)        ;
          sqltext:='update poline'
                    +'  set confirmtime=getdate() '
                    +' where pono='+quotedstr(AdoQry_Mo.fieldbyname('mono').asstring)
                    +'  and polineno='+inttostr(AdoQry_Mo.fieldbyname('MoLineno').asinteger);
          Executesql(AdoQry_tmp,sqltext,1) ;
        end;
      try
        Executesql(AdoQry_tmp,'drop table #topItemList',1)  ;
      except
      end;
      try
        Executesql(AdoQry_tmp,'drop table #tmPmnItemList,#remnItemList',1)  ;
      except
      end;
      AdoQry_Mo.Connection.CommitTrans;
    except
      if ShowAnimate<>nil then ShowAnimate.Free;
      if showpanel<>nil then showpanel.Free;
      if AdoQry_Mo.Connection.InTransaction then AdoQry_Mo.Connection.RollBackTrans;
      DispInfo('订单行 '+quotedstr(AdoQry_Mo.fieldbyname('mono').asstring+'--'+inttostr(AdoQry_Mo.fieldbyname('MoLineno').asinteger))+' 重新产生领料清单出错,请重试!',3);
      abort;
    end;
    AdoQry_Mo.Edit;
    AdoQry_Mo.fieldbyname('CheckFlag').AsInteger := 0;
    AdoQry_Mo.Post;
    AdoQry_Mo.Next;
    end; 
  finally
    AdoQry.Free;
    AdoQry1.Free;
  end;
  if ShowAnimate<>nil then  ShowAnimate.Free;
  if showpanel<>nil then    showpanel.Free;
  DispInfo('重新产生领料清单成功!',3);
  
end;


procedure TFrm_Bas_Qry_BomChange.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  inherited;
  try
    Executesql(AdoQry_tmp,'drop table #BomChange',1);
  except
  end;
  try
    Executesql(AdoQry_tmp,'drop table #Tmp17',1);
  except
  end;
  action:=cafree;
end;

procedure TFrm_Bas_Qry_BomChange.FormCreate(Sender: TObject);
begin
  inherited;
//
end;

procedure TFrm_Bas_Qry_BomChange.DBGridEh1TitleClick(Column: TColumnEh);
var
  BookMArk:String;
begin
  inherited;
  If Trim(Column.Title.Caption)<>'标记' Then
    Abort;
  If AdoQry_Mo.RecordCount=0 Then
    Abort;
  BookMArk:=AdoQry_Mo.BookmArk;
  If Not Flag Then
  begin
    AdoQry_Mo.First;
    While Not AdoQry_Mo.Eof Do
    begin
      AdoQry_Mo.Edit;
      AdoQry_Mo.fieldbyname('CheckFlag').AsInteger:=1;
      AdoQry_Mo.Post;
      AdoQry_Mo.Next;
    end;
  end
  Else
  begin
    AdoQry_Mo.First;
    While Not AdoQry_Mo.Eof Do
    begin
      AdoQry_Mo.Edit;
      AdoQry_Mo.fieldbyname('CheckFlag').AsInteger:=0;
      AdoQry_Mo.Post;
      AdoQry_Mo.Next;
    end;
  end;
  AdoQry_Mo.BookmArk:=BookMArk;
  Flag:=Not Flag;
end;


end.

⌨️ 快捷键说明

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