📄 mrp_enter_oldcommonassignalternative.pas
字号:
begin
inherited;
end;
procedure TFrm_Mrp_Enter_oldcommonAssignAlterNative.DateCheck(Sender: TObject);
begin
If (ActiveControl.Name='DBGridEh1') Or (ActiveControl.Name='ControlBar') Then
Exit;
inherited;
end;
procedure TFrm_Mrp_Enter_oldcommonAssignAlterNative.Act_DeleteLineExecute(Sender: TObject);
begin
if AdoQry_Body.RecordCount=0 then exit;
If DispInfo('确认真的要删除这行吗?',2)<>'y' Then
Abort;
AdoQry_Body.Delete;
end;
procedure TFrm_Mrp_Enter_oldcommonAssignAlterNative.Act_QuitExecute(Sender: TObject);
begin
Close;
end;
procedure TFrm_Mrp_Enter_oldcommonAssignAlterNative.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
// inherited;
end;
procedure TFrm_Mrp_Enter_oldcommonAssignAlterNative.Act_ExcelExecute(Sender: TObject);
begin
//inherited;
DbGridEhToExcel(DbGridEh1);
end;
procedure TFrm_Mrp_Enter_oldcommonAssignAlterNative.getbyProduct(ItemCode: string;qty:real;MoLinedate,mostArtdate:string);
var tmpAdoQry:TAdoQuery;
tmPMoLineno:integer;
begin
tmpAdoQry:=TAdoQuery.Create(Application);
tmpAdoQry.EnableBCD:=False;
try
tmPMoLineno:=AdoQry_Body.RecordCount;
with tmpAdoQry do
begin
Close;
Connection:=dbconnect;
sql.clear;
sql.Text:='select Bom.ItemCode, '
+' Item.ItemName, '
+' Bom.Bomqty, '
+' Uom.UomName '
+' from Bom '
+' join Item on Bom.ItemCode=Item.ItemCode '
+' left outer join Uom on Item.UomCode=Uom.UomCode '
+' where ite_ItemCode='+quotedstr(ItemCode)
+' and BomItemType=4';
Prepared;
open;
if recordCount=0 then exit;
First;
while not eof do
begin
AdoQry_Body.Append;
AdoQry_Body.fieldbyname('MoLineNo').AsInteger:=AdoQry_Body.RecordCount+1;
AdoQry_Body.fieldbyname('LimItOut').AsInteger:=99999999;
AdoQry_Body.fieldbyname('ItemCode').AsString:=fieldbyname('ItemCode').AsString;
AdoQry_Body.fieldbyname('ItemName').AsString:=fieldbyname('ItemName').AsString;
AdoQry_Body.fieldbyname('UomName').AsString:=fieldbyname('UomName').AsString;
AdoQry_Body.fieldbyname('SsQty').AsFloat:=qty*fieldbyname('Bomqty').asfloat;
AdoQry_Body.fieldbyname('MoQty').AsFloat:=qty*fieldbyname('Bomqty').asfloat;
AdoQry_Body.fieldbyname('MoNoFinishQty').AsFloat:=qty*fieldbyname('Bomqty').asfloat;
AdoQry_Body.fieldbyname('MoLineStatus').AsInteger:=5;
AdoQry_Body.fieldbyname('MoLineDate').Asstring:=MoLinedate;
AdoQry_Body.fieldbyname('MoStArtWorkDate').Asstring:=mostArtdate;
AdoQry_Body.fieldbyname('byProduct').Asinteger:=1;
AdoQry_Body.fieldbyname('ParentMoLineno').Asinteger:=tmPMoLineno;
AdoQry_Body.Post;
next;
end;
AdoQry_Body.First;
end;
finally
tmpAdoQry.Free;
end;
end;
procedure TFrm_Mrp_Enter_oldcommonAssignAlterNative.deletebyProduct(MoLineno: integer);
var tmPmArk:string;
tmplineno:integer;
Count:integer;
begin
tmPmArk:=AdoQry_Body.BookmArk;
Count:=AdoQry_Body.RecordCount;
tmplineno:=AdoQry_Body.fieldbyname('MoLineno').asinteger;
with AdoQry_Body do
begin
First;
while Count>0 do
begin
if AdoQry_Body.fieldbyname('ParentMoLineno').asinteger=tmplineno then
AdoQry_Body.Delete;
next;
Count:=Count-1;
end;
end;
AdoQry_Body.BookmArk:=tmPmArk;
end;
procedure TFrm_Mrp_Enter_oldcommonAssignAlterNative.Act_ModifyExecute(
Sender: TObject);
var BookmArk:string;
begin
try
BookmArk:=AdoQry_Body.BookmArk;
inherited;
finally
activecontrol:=dbgrideh;
dbgrideh.SetFocus;
AdoQry_Body.BookmArk:=BookmArk;
end;
end;
procedure TFrm_Mrp_Enter_oldcommonAssignAlterNative.sumItemss(ItemCode,
releasedate: string; ssqty: real);
var tmpQry:TAdoQuery;
sqltext:string;
begin
if not existsItemss(ItemCode,releasedate) then exit;
tmpQry:=TAdoQuery.Create(self);
tmpQry.Connection:=dbconnect;
sqltext:='update ss'
+' set ssqty=ssqty+'+floattostr(ssqty)+','
+' reMainqty=reMainqty+'+floattostr(ssqty)
+' where ItemCode='+quotedstr(ItemCode)
+' and ssdate='+quotedstr(releasedate)
+' and ssSysInfoflag=1 ';
try
Executesql(tmpQry,sqltext,1);
finally
tmpQry.Free;
end;
end;
procedure TFrm_Mrp_Enter_oldcommonAssignAlterNative.insertss;
var sqltext:string;
begin
SqlText:='insert into Ss(ItemCode,ssSysInfoflag,ssdate,PmType,duedate,ssqty,reMainqty) '
+'Values('+quotedstr(AdoQry_Body.fieldbyname('ItemCode').asstring)+','
+'1,'
+quotedstr(AdoQry_Body.fieldbyname('ssdate').asstring)+','
+inttostr(AdoQry_Body.fieldbyname('PmType').asinteger)+','
+quotedstr(AdoQry_Body.fieldbyname('duedate').asstring)+','
+floattostr(AdoQry_Body.fieldbyname('ssqty').asfloat)+','
+floattostr(AdoQry_Body.fieldbyname('ssqty').asfloat)+')';
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:=SqlText;
try
AdoQry_Tmp.ExecSQL;
except
end;
end;
function TFrm_Mrp_Enter_oldcommonAssignAlterNative.existsItemss(ItemCode,
releasedate: string): boolean;
var AdoQry:TAdoQuery;
sqltext:string;
begin
Result:=False;
AdoQry:=TAdoQuery.Create(nil);
AdoQry.Connection:=AdoQry_Body.Connection;
sqltext:='select * from ss '
+' where ItemCode='+quotedstr(ItemCode)
+' and ssdate='+quotedstr(releasedate)
+' and ssSysInfoflag=1 ';
try
Executesql(AdoQry,sqltext,0);
if AdoQry.RecordCount>0 then Result:=True;
finally
AdoQry.Free;
end;
end;
procedure TFrm_Mrp_Enter_oldcommonAssignAlterNative.setite_ItemInfo(
ssid: integer);
var AdoQry:TAdoQuery;
sqltext:string;
begin
AdoQry:=TAdoQuery.Create(nil);
AdoQry.Connection:=dbconnect;
sqltext:='select ss.*,'
+' ss.ItemCode+'' ''+Item.ItemName as Itemflag,'
+' Uom.UomName'
+' from ss '
+' join Item on ss.ItemCode=Item.ItemCode '
+' left outer join Uom on Item.UomCode=Uom.UomCode '
+' where ss.ssid='+inttostr(ssid);
try
Executesql(AdoQry,sqltext,0);
ite_Ssid:=ssid;
ite_ItemCode:=AdoQry.fieldbyname('ItemCode').asstring;
ite_reMainqty:=AdoQry.fieldbyname('reMainqty').asfloat;
lbl_Item.Caption:=AdoQry.fieldbyname('Itemflag').asstring;
label2.Caption:=AdoQry.fieldbyname('UomName').asstring;
label5.Caption:='建议下达';
label8.Caption:=AdoQry.fieldbyname('ssdate').asstring;
label12.Caption:=floattostr(AdoQry.fieldbyname('ssqty').asfloat);
label14.Caption:=floattostr(AdoQry.fieldbyname('reMainqty').asfloat);
finally
AdoQry.Free;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -