📄 mrp_enter_editpassmo.pas
字号:
While Not AdoQry_Head.Eof Do
If (AdoQry_Head.fieldbyname('MoLineCheck').AsInteger=1) And (AdoQry_Head.fieldbyname('MoLineStatus').AsInteger=5) Then
begin
sqltext:='select * from MoLine where MoLinestatus=5 '
+'and MoNo='''+AdoQry_Head.fieldbyname('MoNo').AsString+''''
+' And MoLineNo='''+IntToStr(AdoQry_Head.fieldbyname('MoLineNo').AsInteger)+'''';
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_EditPassMo.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_EditPassMo.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_EditPassMo.AdoQry_HeadBeforeEdit(DataSet: TDataSet);
begin
inherited;
if AdoQry_Head.fieldbyname('byProduct').asinteger=1 then
begin
DispInfo('这行是副产品,不能执行选定操作!',3);
abort;
end;
end;
procedure TFrm_Mrp_Enter_EditPassMo.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_EditPassMo.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_EditPassMo.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_EditPassMo.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_EditPassMo.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_EditPassMo.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 '
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -