📄 qc_checkresult3.pas
字号:
AdoQry_Tmp.Sql.Add('Update OnCheckBillLine '+
' Set ReceivedQty='+
floattostr(AdoQry_Main.fieldbyname('ReceivedQTy').Asfloat)+','+
' QcStatus='+AdoQry_Main.fieldbyname('QcStatus').AsString+','+
' QcBatchNo='''+AdoQry_Main.fieldbyname('QcBatchNo').AsString+''','+
' QcEmployeeCode='''+UserCode+''','+
' QcLevel='''+AdoQry_Main.fieldbyname('QcLevel').AsString+''','+
' QcRemArk='''+AdoQry_Main.fieldbyname('OnCheckRemArk').AsString+''' '+
' Where OnCheckBillId='+AdoQry_Main.fieldbyname('OnCheckBillId').AsString+
' and OnCheckBillLineNo='+AdoQry_Main.fieldbyname('OnCheckBillLineNo').AsString);
AdoQry_Tmp.ExecSql;
end;
IF (AdoQry_Main.fieldbyname('QcStatus').AsFloat=2) then //质量状态等于拒收
With AdoQry_Tmp do
begin
Close;
Sql.clear;
Sql.Add('Select WHCode '+
'From OnCheckBill '+
'Where OnCheckBillId='+AdoQry_Main.fieldbyname('OnCheckBillId').AsString);
Open;
WarehouseCode:=AdoQry_Tmp.fieldbyname('WHCode').AsString;
Close;
Sql.clear;
Sql.Add('Select WhPositionCode '+
'From WhPosition '+
'Where WhCode='+format('''%s''',[WarehouseCode])+' and WhPositionType=1 ');
Open;
WhPositionCode:=AdoQry_Tmp.fieldbyname('WhPositionCode').AsString;
Close;
Sql.clear;
Sql.Add('Update CurrentInv '+ //直接减少待检量,此做法值商酌
'Set OnCheckInv=OnCheckInv-('+AdoQry_Main.fieldbyname('OnCheckQty').AsString+') '+
'Where WhCode='''+WarehouseCode+''' '+
'And ItemCode='''+AdoQry_Main.fieldbyname('ItemCode').AsString+''' '+
'And WhPositionCode='''+WhPositionCode+'''');
ExecSql;
Close;
SQl.clear;
Sql.Add('Update Item '+
'Set CurrentOnCheckInv=CurrentOnCheckInv-('+AdoQry_Main.fieldbyname('OnCheckQty').AsString+') '+
'Where ItemCode='''+AdoQry_Main.fieldbyname('ItemCode').AsString+'''');
ExecSql;
Close;
SQl.clear;
Sql.Add('Select b.PoNo,bl.PoLineNo '+
'From OnCheckBillLine bl,oncheckBill b '+
'Where bl.OnCheckBillId='+AdoQry_Main.fieldbyname('OnCheckBillId').AsString+
' And bl.OnCheckBillLineNo='+AdoQry_Main.fieldbyname('OnCheckBillLineNo').AsString+
' And bl.OnCheckBillid=b.oncheckBillid');
Open;
PoNo:=fieldbyname('PoNo').AsString;
PoLineNo:=fieldbyname('PoLineNo').AsString;
Close;
Sql.clear;
Sql.Add('Update MoLine '+
'Set MoOnCheckQty=MoOnCheckQty-('+AdoQry_Main.fieldbyname('OnCheckQty').AsString+') ' +
'Where MONo='''+PoNo+''' '+
'And MoLineNo='''+PoLineNo+'''');
ExecSql;
Close;
Sql.Text:='Update OnCheckBillLine'+
' Set ReceivedQty=0,'+ // '+AdoQry_Main.fieldbyname('ReceivedQTy').AsString+','+
' QcBatchNo='''+AdoQry_Main.fieldbyname('QcBatchNo').AsString+''','+
' QcStatus='+AdoQry_Main.fieldbyname('QcStatus').AsString+','+
' QcEmployeeCode='''+UserCode+''','+
' OnCheckStatus=1,'+//'+AdoQry_Main.fieldbyname('OnCheckStatus').AsString+','+
' QcRemArk='''+AdoQry_Main.fieldbyname('OnCheckRemArk').AsString+''''+
' Where OnCheckBillId='+AdoQry_Main.fieldbyname('OnCheckBillId').AsString+
' and OnCheckBillLineNo='+AdoQry_Main.fieldbyname('OnCheckBillLineNo').AsString;
ExecSql;
end;
end;
{function TFrm_Qc_CheckResult.save_Check: boolean;
var
WarehouseCode,WhPositionCode,PoNo,PoLineNo :String;
begin
{ If (AdoQry_Main.fieldbyname('ReceivedQty').AsFloat<0) or
(AdoQry_Main.fieldbyname('ReceivedQty').AsFloat>
AdoQry_Main.fieldbyname('OnCheckQty').AsFloat) then
begin
Result:=True;
exit;
end;
If (AdoQry_Main.fieldbyname('Qcstatus').asstring<>'0')and
(AdoQry_Main.fieldbyname('Qcstatus').asstring<>'2')and
( display<>1 )
and
(AdoQry_Main.fieldbyname('ReceivedQty').asfloat=0) then
begin
DispInfo('质检判定后的物料数量不能为零!',1);
Abort;
end;
If (AdoQry_Main.fieldbyname('Qcstatus').asstring<>'0') and
(AdoQry_Main.fieldbyname('QcBatchNo').asstring='') then
begin
DispInfo('质检判定后必须有质检控制号!',1);
Abort;
end;
//if (AdoQry_Main.fieldbyname('ReceivedQty').asfloat<>0)and
If AdoQry_Main.fieldbyname('QcStatus').AsFloat<>2 then
If Display=1 then
begin
with AdoQry_tmp do
begin
Close;
Sql.text:='Insert OnCheckBillLineHistory(OnCheckBillId,OnCheckBillLineNo,ItemCode,OnCheckQty,ReceivedQty,'+
'QcStatus,OnCheckStatus,POLineNo,BillLineRemArk,BatchNo,chgtime,chgEmployeeCode,chgType) '+
' Select OnCheckBillId,OnCheckBillLineNo,ItemCode,OnCheckQty,ReceivedQty,'+
'QcStatus,OnCheckStatus,POLineNo,BillLineRemArk,BatchNo,'+
'Getdate(),QuotedStr(userCode)+
',''质检判定'' '+
'From oncheckBillline '
'Where OnCheckBillId='+
AdoQry_Main.fieldbyname('OnCheckBillId').asstring+
'And oncheckBilllineno='+AdoQry_Main.fieldbyname('oncheckBilllineno').asstring;
Execsql;
Close;
Sql.clear;
Sql.Add('Update OnCheckBillLine '+
' Set ReceivedQty='+
floattostr(AdoQry_Main.fieldbyname('OnCheckQty').Asfloat)+','+
' QcStatus='+AdoQry_Main.fieldbyname('QcStatus').AsString+','+
' QcBatchNo='''+AdoQry_Main.fieldbyname('QcBatchNo').AsString+''','+
' QcEmployeeCode='''+UserCode+''','+
' QcLevel='''+AdoQry_Main.fieldbyname('QcLevel').AsString+''','+
' QcRemArk='''+AdoQry_Main.fieldbyname('OnCheckRemArk').AsString+''','+
' OnCheckStatus='+AdoQry_Main.fieldbyname('OnCheckStatus').AsString+' '+
' Where OnCheckBillId='+AdoQry_Main.fieldbyname('OnCheckBillId').AsString+
' and OnCheckBillLineNo='+AdoQry_Main.fieldbyname('OnCheckBillLineNo').AsString);
ExecSql;
end;
end
else
begin
With AdoQry_Tmp do
begin
Close;
sql.text:='insert OnCheckBillLineHistory(OnCheckBillId,OnCheckBillLineNo,ItemCode,OnCheckQty,ReceivedQty'
+',QcStatus,OnCheckStatus,POLineNo,BillLineRemArk,BatchNo,chgtime,chgEmployeeCode,chgType)'
+' select OnCheckBillId,OnCheckBillLineNo,ItemCode,OnCheckQty,ReceivedQty'
+',QcStatus,OnCheckStatus,POLineNo,BillLineRemArk,BatchNo,'
+' getdate(),'
+QuotedStr(userCode)
+',''质检判定'' from oncheckBillline Where OnCheckBillId='
+AdoQry_Main.fieldbyname('OnCheckBillId').asstring
+' and oncheckBilllineno='+AdoQry_Main.fieldbyname('oncheckBilllineno').asstring;
execsql;
Close;
Sql.clear;
Sql.Add('Update OnCheckBillLine '+
' Set ReceivedQty='+
floattostr(AdoQry_Main.fieldbyname('ReceivedQTy').Asfloat)+','+
' QcStatus='+AdoQry_Main.fieldbyname('QcStatus').AsString+','+
' QcBatchNo='''+AdoQry_Main.fieldbyname('QcBatchNo').AsString+''','+
' QcEmployeeCode='''+UserCode+''','+
' QcLevel='''+AdoQry_Main.fieldbyname('QcLevel').AsString+''','+
' QcRemArk='''+AdoQry_Main.fieldbyname('OnCheckRemArk').AsString+''' '+
// ' OnCheckStatus='+AdoQry_Main.fieldbyname('OnCheckStatus').AsString+' '+
' Where OnCheckBillId='+AdoQry_Main.fieldbyname('OnCheckBillId').AsString+
' and OnCheckBillLineNo='+AdoQry_Main.fieldbyname('OnCheckBillLineNo').AsString);
ExecSql;
end;
end;
IF (AdoQry_Main.fieldbyname('QcStatus').AsFloat=2) then
With AdoQry_Tmp do
begin
Close;
Sql.clear;
Sql.Add('Select WHCode From OnCheckBill Where OnCheckBillId='+AdoQry_Main.fieldbyname('OnCheckBillId').AsString);
Open;
WarehouseCode:=AdoQry_Tmp.fieldbyname('WHCode').AsString;
Close;
Sql.clear;
Sql.Add('Select WhPositionCode From WhPosition Where WhCode='+format('''%s''',[WarehouseCode])+' and WhPositionType=1 ');
Open;
WhPositionCode:=AdoQry_Tmp.fieldbyname('WhPositionCode').AsString;
Close;
Sql.clear;
Sql.Add('Update CurrentInv '+
' Set OnCheckInv=OnCheckInv-('+AdoQry_Main.fieldbyname('OnCheckQty').AsString+') '+
' Where WhCode='''+WarehouseCode+''''+
' and ItemCode='''+AdoQry_Main.fieldbyname('ItemCode').AsString+''''+
' and WhPositionCode='''+WhPositionCode+'''');
ExecSql;
Close;
SQl.clear;
Sql.Add('Update Item '+
' Set CurrentOnCheckInv=CurrentOnCheckInv-('+AdoQry_Main.fieldbyname('OnCheckQty').AsString+') '+
' Where ItemCode='''+AdoQry_Main.fieldbyname('ItemCode').AsString+'''');
ExecSql;
Close;
SQl.clear;
Sql.Add('Select b.PoNo,bl.PoLineNo From OnCheckBillLine bl,oncheckBill b '+
' Where bl.OnCheckBillId='+AdoQry_Main.fieldbyname('OnCheckBillId').AsString+
' and bl.OnCheckBillLineNo='+AdoQry_Main.fieldbyname('OnCheckBillLineNo').AsString+
' and bl.OnCheckBillid=b.oncheckBillid');
Open;
PoNo:=fieldbyname('PoNo').AsString;
PoLineNo:=fieldbyname('PoLineNo').AsString;
Close;
Sql.clear;
Sql.Add('Update PoLine '+
' Set PoInQty=PoInQty-('+AdoQry_Main.fieldbyname('OnCheckQty').AsString+')' +
' Where PONo='''+PoNo+''''+
' and PoLineNo='''+PoLineNo+'''');
ExecSql;
Close;
sql.text:='insert OnCheckBillLineHistory(OnCheckBillId,OnCheckBillLineNo,ItemCode,OnCheckQty,ReceivedQty'
+',QcStatus,OnCheckStatus,POLineNo,BillLineRemArk,BatchNo,chgtime,chgEmployeeCode,chgType)'
+' select OnCheckBillId,OnCheckBillLineNo,ItemCode,OnCheckQty,ReceivedQty'
+',QcStatus,OnCheckStatus,POLineNo,BillLineRemArk,BatchNo,'
+' getdate(),'
+QuotedStr(userCode)
+',''质检判定'' from oncheckBillline Where OnCheckBillId='
+AdoQry_Main.fieldbyname('OnCheckBillId').asstring
+' and oncheckBilllineno='+AdoQry_Main.fieldbyname('oncheckBilllineno').asstring;
execsql;
Close;
sql.Text:='update OnCheckBillLine'+
' Set ReceivedQty='+AdoQry_Main.fieldbyname('ReceivedQTy').AsString+','+
' QcBatchNo='''+AdoQry_Main.fieldbyname('QcBatchNo').AsString+''','+
' QcStatus='+AdoQry_Main.fieldbyname('QcStatus').AsString+','+
' QcEmployeeCode='''+UserCode+''','+
' OnCheckStatus='+AdoQry_Main.fieldbyname('OnCheckStatus').AsString+','+
' QcRemArk='''+AdoQry_Main.fieldbyname('OnCheckRemArk').AsString+''''+
' Where OnCheckBillId='+AdoQry_Main.fieldbyname('OnCheckBillId').AsString+
' and OnCheckBillLineNo='+AdoQry_Main.fieldbyname('OnCheckBillLineNo').AsString;
execsql;
end;
end;}
procedure TFrm_Qc_CheckResult3.Act_QuitExecute(Sender: TObject);
begin
inherited;
//
end;
procedure TFrm_Qc_CheckResult3.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
if Not AdoQry_Main.IsEmpty then
if (act_Save.Enabled=True) and (DispInfo('要保存数据吗?',2)='y') then
act_Save.OnExecute(sender);
//inherited;
if Frm_Sys_Condition<>nil then
Frm_Sys_Condition.Release;
if Frm_Sys_Detail<>nil then
Frm_Sys_Detail.Release;
if Frm_Sys_SortOrder<>nil then
Frm_Sys_SortOrder.Release;
if Frm_Sys_QuickLocate<>nil then
Frm_Sys_QuickLocate.Release;
if Frm_Sys_SetColumn<>nil then
Frm_Sys_SetColumn.Release;
Action:=CaFree;
end;
procedure TFrm_Qc_CheckResult3.AdoQry_MainAfterPost(DataSet: TDataSet);
begin
inherited;
act_Save.Enabled:=True;
end;
function TFrm_Qc_CheckResult3.Check_QcBatchNo(QcBatchno,
ItemCode,VendorCode: string): Boolean;
var
I:Integer;
mypost:TDataSetNotifyEvent;
Book1:TBookMArk;
begin
mypost:=AdoQry_Main.BeforePost;
AdoQry_Main.BeforePost:=nil;
Book1:=AdoQry_Main.GetBookmArk;
Result:=True;
with AdoQry_Tmp do
begin
Close;
sql.Text:='select OB.ItemCode,OCB.VendorCode '+
' from OnCheckBillLine OB '+
' Join OnCheckBill OCB '+
' on OCB.OnCheckBillId=OB.OnCheckBillId '+
' where QcBatchNo='''+QcBatchNo+'''';
open;
if IsEmpty then
begin
//DBGridEh.Columns[1].field
AdoQry_Main.First;
for I:=0 to AdoQry_Main.recordCount-1 do
begin
If ((AdoQry_Main.fieldbyname('QcBatchNo').asstring=QcBatchNO) and
((AdoQry_Main.fieldbyname('ItemCode').asstring<>ItemCode)or
(AdoQry_Main.fieldbyname('VendorCode').asstring<>VendorCode))) then
begin
Result:=False;
AdoQry_Main.next;
AdoQry_Main.GotoBookmArk(Book1);
AdoQry_Main.FreeBookmArk(Book1);
AdoQry_Main.BeforePost:=mypost;
AdoQry_Main.edit;
AdoQry_Main.fieldbyname('QcBatchNO').asstring:='';
exit;
end;
AdoQry_Main.Next;
end;
end
else
if (fieldbyname('ItemCode').asstring<>ItemCode)or
(fieldbyname('VendorCode').asstring<>VendorCode)
then Result:=False
else Result:=True;
end;
AdoQry_Main.GotoBookmArk(Book1);
AdoQry_Main.FreeBookmArk(Book1);
AdoQry_Main.BeforePost:=mypost;
end;
procedure TFrm_Qc_CheckResult3.AdoQry_MainAfterScroll(DataSet: TDataSet);
begin
inherited;
if AdoQry_Main.eof then
begin
AdoQry_Main.Cancel;
end;
end;
procedure TFrm_Qc_CheckResult3.Act_autoExecute(Sender: TObject);
var
saveplace:TBookmArk;
begin
inherited;
if AdoQry_Main.Active then
begin
saveplace:=AdoQry_Main.GetBookmArk ;
AdoQry_Main.First ;
AdoQry_Main.Edit;
while not AdoQry_Main.Eof do
begin
if (AdoQry_Main.fieldbyname ('QcStatus').asinteger<>0) and ( AdoQry_Main.fieldbyname ('QcStatus').asinteger<>2) then
begin
AdoQry_Main.Edit;
AdoQry_Main.fieldbyname('ReceivedQty').asfloat:=AdoQry_Main.fieldbyname('OnCheckQty').asfloat;
end;
AdoQry_Main.next;
end;
AdoQry_Main.GotoBookmArk (saveplace);
AdoQry_Main.FreeBookmArk (saveplace);
end;
end;
procedure TFrm_Qc_CheckResult3.Act_FilterExecute(Sender: TObject);
begin
inherited;
DBGridEh.Columns[10].ReadOnly:=False;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -