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

📄 mrp_enter_passmo.pas

📁 一个MRPII系统源代码版本
💻 PAS
📖 第 1 页 / 共 5 页
字号:
           AdoQry_Tmp.Close;
          AdoQry_Tmp.SQL.Text:=SqlText;
          AdoQry_tmp.open;
          if AdoQry_tmp.RecordCount=0 then
            begin
             AdoQry_Head.Next;
             continue;
            end;

          sqltext:='delete from mnItemList'
                  +' where mono='+quotedstr(AdoQry_Head.fieldbyname('MoNo').asstring)
                  +' and MoLineNo='+inttostr(AdoQry_Head.fieldbyname('MoLineNo').asinteger);
          AdoQry_Tmp.Close;
          AdoQry_Tmp.SQL.Text:=SqlText;
          AdoQry_tmp.ExecSQL;
          saveMoLineHistory(dbconnect,AdoQry_Head.fieldbyname('mono').asstring,AdoQry_Head.fieldbyname('MoLineno').asinteger,userCode,2);
          SqlText:=' delete From MoLine '
                  +' Where MoNo='''+AdoQry_Head.fieldbyname('MoNo').AsString+''''
                  +' And MoLineNo='''+IntToStr(AdoQry_Head.fieldbyname('MoLineNo').AsInteger)+''''
                  +' And MoLineStatus=5 ';
          AdoQry_Tmp.Close;
          AdoQry_Tmp.SQL.Text:=SqlText;
          AdoQry_tmp.ExecSQL;
          SqlText:=' select * From MoLine '
                  +' Where MoNo='''+AdoQry_Head.fieldbyname('MoNo').AsString+''''
                  +' And ParentMoLineNo='''+IntToStr(AdoQry_Head.fieldbyname('MoLineNo').AsInteger)+''''
                  +' and byProduct=1';
          AdoQry_Tmp.Close;
          AdoQry_Tmp.SQL.Text:=SqlText;
          AdoQry_tmp.open;
          AdoQry_tmp.First;
          while not AdoQry_tmp.Eof do
           begin
            saveMoLineHistory(dbconnect,AdoQry_tmp.fieldbyname('mono').asstring,AdoQry_tmp.fieldbyname('MoLineno').asinteger,userCode,2);
            AdoQry_tmp.next;
           end;

          SqlText:=' delete From MoLine '
                  +' Where MoNo='''+AdoQry_Head.fieldbyname('MoNo').AsString+''''
                  +' And ParentMoLineNo='''+IntToStr(AdoQry_Head.fieldbyname('MoLineNo').AsInteger)+''''
                  +' and byProduct=1';
          AdoQry_Tmp.Close;
          AdoQry_Tmp.SQL.Text:=SqlText;
          AdoQry_tmp.ExecSQL;
          SqlText:=' select * from  Mo '
                  +' Where MoNo='''+AdoQry_Head.fieldbyname('MoNo').AsString+''''
                  +' And not exists(select * from MoLine where  MoNo='''+AdoQry_Head.fieldbyname('MoNo').AsString+''''+')';
          AdoQry_tmp.Close;
          AdoQry_tmp.SQL.Text:=SqlText;
          AdoQry_tmp.open;
          if AdoQry_tmp.RecordCount>0 then
            savemohistory(dbconnect,AdoQry_tmp.fieldbyname('mono').asstring,userCode,2);
          SqlText:=' delete from  Mo '
                  +' Where MoNo='''+AdoQry_Head.fieldbyname('MoNo').AsString+''''
                  +' And not exists(select * from MoLine where  MoNo='''+AdoQry_Head.fieldbyname('MoNo').AsString+''''+')';
          AdoQry_tmp.Close;
          AdoQry_tmp.SQL.Text:=SqlText;
          AdoQry_tmp.ExecSQL;
          AdoQry_Head.delete;
          I:=I+1;
        end
        Else
        begin
          I:=I+1;
          AdoQry_Head.Next;
        end;
      DbConnect.CommitTrans;
    Except
      If DbConnect.InTransaction Then
        DbConnect.RollBackTrans;
      DispInfo('删除订单时发生错误,订单未删除,请重试!',3);
      AdoQry_Head.BookMArk:=BookmArk;
      Abort;
    end;
  end;
  AdoQry_Head.ReQuery;
 try
//   if ((AdoQry_Head.RecordCount>0) and (not AdoQry_Head.Eof))then
  AdoQry_Head.BookMArk:=BookmArk;
 except
 end;

end;

function TFrm_Mrp_Enter_PassMo.getPmCode(ItemCode: string): integer;
begin
try
 Executesql(AdoQry_tmp,'select PmCode from Item where ItemCode='+quotedstr(ItemCode),0);
 Result:=AdoQry_tmp.fieldbyname('PmCode').asinteger;
except
 Result:=255;
end;
end;
function TFrm_Mrp_Enter_PassMo.getQclt(ItemCode: string): string;
begin
try
 Executesql(AdoQry_tmp,'select Qclt from Item where ItemCode='+quotedstr(ItemCode),0);
 Result:=inttostr(AdoQry_tmp.fieldbyname('Qclt').asinteger);
except
 Result:='9999999';
end;
end;

procedure TFrm_Mrp_Enter_PassMo.AdoQry_HeadBeforeEdit(DataSet: TDataSet);
begin
  inherited;
  if AdoQry_Head.fieldbyname('byProduct').asinteger=1 then
    begin
     DispInfo('这行是副产品,不能执行选定操作!',3);
     abort;
    end;
end;

procedure TFrm_Mrp_Enter_PassMo.PassbyProduct;
var    tmpbeforeedit:Tdatasetnotifyevent;
begin
Tmpbeforeedit:=AdoQry_Head.BeforeEdit;
AdoQry_Head.BeforeEdit:=nil;
AdoQry_Head.Edit;
AdoQry_Head.fieldbyname('MoLineStatus').AsInteger:=6;
AdoQry_Head.fieldbyname('MoLineCheck').AsInteger:=0;
AdoQry_Head.Post;
AdoQry_Head.BeforeEdit:=Tmpbeforeedit;
end;

function TFrm_Mrp_Enter_PassMo.existsnoPassmo(mono: string;
  MoLineno: integer): boolean;
var sqltext:string;
    AdoQry:TAdoQuery;
begin
 Result:=True;
 SqlText:=' Select * From MoLine '
         +' Where MoNo='''+mono+''''
         +' And MoLineNo='''+IntToStr(MoLineno)+''''
         +' And MoLineStatus=5 ';
 AdoQry:=TAdoQuery.Create(self);
  AdoQry.Connection:=dbconnect;
 try
 AdoQry.Close;
 AdoQry.SQL.Text:=SqlText;
 AdoQry.Open;
 if AdoQry.RecordCount=0 then Result:=False
 else isBackflush:=AdoQry.fieldbyname('Backflush').asinteger;
 finally
 AdoQry.Free;
 end;
end;

procedure TFrm_Mrp_Enter_PassMo.PassMoLine(mono: string;
  MoLineno: integer);
var sqltext:string;
    AdoQry:TAdoQuery;
begin
  SqlText:=' Update MoLine '
           +' set MoLineStatus=6'
           +' Where MoNo='''+mono+''''
           +' And  MoLineNo='''+inttostr(MoLineno)+''''
           +' And MoLineStatus=5 ';
 AdoQry:=TAdoQuery.Create(self);
  AdoQry.Connection:=dbconnect;
 try
 AdoQry.Close;
 AdoQry.SQL.Text:=SqlText;
 AdoQry.execsql;
 finally
 AdoQry.Free;
 end;

end;

procedure TFrm_Mrp_Enter_PassMo.PassbyProductMoLine(mono: string;
  MoLineno: integer);
var sqltext:string;
    AdoQry:TAdoQuery;
begin
  SqlText:=' Update MoLine '
           +' set MoLineStatus=6'
           +' Where MoNo='''+mono+''''
           +' And  ParentMoLineNo='''+inttostr(MoLineno)+''''
           +' And MoLineStatus=5 ';
 AdoQry:=TAdoQuery.Create(self);
  AdoQry.Connection:=dbconnect;
 try
 AdoQry.Close;
 AdoQry.SQL.Text:=SqlText;
 AdoQry.execsql;
 finally
 AdoQry.Free;
 end;

end;


procedure TFrm_Mrp_Enter_PassMo.savebyProducthistory(mono: string;
  MoLineno: integer);
var sqltext:string;
    AdoQry:TAdoQuery;
begin
  SqlText:=' select * from MoLine '
           +' Where MoNo='''+mono+''''
           +' And  ParentMoLineNo='''+inttostr(MoLineno)+''''
           +' And MoLineStatus=5 '
           +' and byProduct=1 ';
  AdoQry:=TAdoQuery.Create(self);
  AdoQry.Connection:=dbconnect;
  try
   AdoQry.Close;
   AdoQry.SQL.Text:=SqlText;
   AdoQry.open;
   AdoQry.First;
   while not AdoQry.Eof do
    begin
     saveMoLineHistory(dbconnect,AdoQry.fieldbyname('mono').asstring,AdoQry.fieldbyname('MoLineno').asinteger,userCode,3);
     AdoQry.next;
    end;
  finally
   AdoQry.Free;
  end;

end;



function TFrm_Mrp_Enter_PassMo.checkCurrentonhandInv(mono: string;
  MoLineno: integer; var haveInv: integer; var strWhName: string): boolean;
var AdoQry:TAdoQuery;
    sqltext:string;
begin
  Result:=False;
  AdoQry:=TAdoQuery.Create(self);
  AdoQry.Connection:=dbconnect;
try
  sqltext:='Select mnItemList.ItemCode,BatchCtrl,Sum(MoCtrlQty) As MOCtrlQty  '
           +'  into #themnItemList '
           +'              From MNItemList,Item     '
           +'              Where MoNO='+quotedstr(mono)
           +'                and MoLineno='+inttostr(MoLineno)
           +'                and mnItemList.ItemCode=Item.ItemCode '
           +'              Group By mnItemList.ItemCode,Item.BatchCtrl ';
  //汇总领料清单中各物料要领量总数
  Executesql(AdoQry,sqltext,1);
  sqltext:=' Select CurrentInv.ItemCode,Sum(OnHandInv) As OnHandInv '
           +'    into #theCurrentInv                                 '
           +'  From CurrentInv,#themnItemList                        '
           +'  Where CurrentInv.ItemCode =#TheMNItemList.ItemCode    '
           +'    And CurrentInv.WHCode In (Select Distinct WHCode     '
           +'                From WhPosition                          '
           +'               Where WhPositionType=0 And BackFlushWHP=1 And DeptCode='+quotedstr(getDeptCode(mono))+' )'
           +'    And CurrentInv.WHCode+CurrentInv.WhPositionCode Not In (Select WHCode+WhPositionCode  '
           +'                                              From WhPosition            '
           +'                                              Where BackFlushWHP=1)      '
           +'    And CurrentInv.WHCode+CurrentInv.WhPositionCode In (Select WHCode+WhPositionCode  '
           +'                                           From WhPosition                         '
           +'                                         Where WhPositionType=0  )                '
           +'    Group By CurrentInv.ItemCode   ';
 { sqltext:='Select Item.ItemCode,(Item.CurrentOnHandInv-Item.BackFlushAllocInv)-#theMNItemList.MoCtrlQty As ReMainInv '
           +'   From Item       '
           +' Join #theMNItemList On Item.ItemCode=#theMNItemList.ItemCode   '
     +'  Where (Item.CurrentOnHandInv-Item.BackFlushAllocInv)<#theMNItemList.MoCtrlQty ';}
  //判断当前库存数是否够领量数,如果选出的记录数大于0则表示有子项不够库存
  Executesql(AdoQry,sqltext,1);
    sqltext:='Select Batch.ItemCode,sum(BatchCurrentInv.InvQty) as onhandInv  '

⌨️ 快捷键说明

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