📄 qc_reclaim.pas
字号:
unit Qc_Reclaim;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Outer, Menus, ExtPrintReport, Db, ActnList, AdODB, Grids, DBGridEh,
StdCtrls, ExtCtrls, ComCtrls, ToolWin,dbgrids, jpeg;
Type
TFrm_Qc_Reclaim = Class(TFrm_Base_Outer)
AdoQry_MainItemCode: TStringField;
AdoQry_MainOncheckBillId: TIntegerField;
AdoQry_MainOnCheckBillLineNo: TIntegerField;
AdoQry_MainItemName: TStringField;
AdoQry_MainUomName: TStringField;
AdoQry_MainOnCheckBillNo: TStringField;
AdoQry_MainOnCheckDate: TDateTimeField;
AdoQry_MainOnCheckQty: TFloatField;
AdoQry_MainOnCheckStatus: TIntegerField;
AdoQry_MainReceivedQty: TFloatField;
AdoQry_MainQcStatus: TIntegerField;
AdoQry_MainQcStatusbak: TIntegerField;
AdoQry_MainReceivedQtybak: TFloatField;
AdoQry_MainOnCheckRemArk: TStringField;
AdoQry_MainOnCheckRemArkbak: TStringField;
AdoQry_MainBatchNo: TStringField;
AdoQry_MaInvendorCode: TStringField;
AdoQry_MaInvendorflag: TStringField;
AdoQry_MainQcBatchNo: TStringField;
procedure Act_CheckExecute(Sender: TObject);
procedure AdoQry_MainBeforePost(DataSet: TDataSet);
procedure FormActivate(Sender: TObject);
procedure AdoQry_MainAfterPost(DataSet: TDataSet);
procedure AdoQry_MainAfterScroll(DataSet: TDataSet);
private
procedure Process_Reclaim(id,ItemCode,LineNo,ReMArk:string;Receivedqty:real);
{ Private declarations }
public
procedure ChangeGridStatus(status:Boolean);
procedure InitForm(AdOConnection:TAdOConnection;ReadOnly:Boolean);OverRide;
{ Public declarations }
end;
var
Frm_Qc_Reclaim: TFrm_Qc_Reclaim;
implementation
uses Sys_Global,Qc_Reclaim_C;
{$R *.DFM}
{ TFrm_Qc_Reclaim }
procedure TFrm_Qc_Reclaim.ChangeGridStatus(status: Boolean);
begin
with DBGridEh do
begin
ReadOnly:=status;
Columns[0].ReadOnly:=not status;
Columns[1].ReadOnly:=not status;
Columns[2].ReadOnly:=not status;
Columns[3].ReadOnly:=not status;
Columns[4].ReadOnly:=not status;
Columns[5].ReadOnly:=not status;
Columns[6].ReadOnly:=not status;
Columns[7].ReadOnly:=not status;
Columns[8].ReadOnly:=not status;
Columns[9].ReadOnly:=status;
Columns[10].ReadOnly:=status;
Columns[11].ReadOnly:=not status;
Columns[12].ReadOnly:=not status;
Columns[13].ReadOnly:=status;
end;
end;
procedure TFrm_Qc_Reclaim.InitForm(AdOConnection: TAdOConnection;
ReadOnly: Boolean);
begin
inherited;
AdoQry_Main.Connection:=AdOConnection;
AdoQry_Tmp.Connection:=AdOConnection;
ToolButton6.Action:=Act_Check;
with DBGridEh do
begin
options:=options+[dgEditing]-[dgRowSelect];
end;
SelectFromSQL:='select OnCheckBillLine.OnCheckStatus,'+
'OnCheckBillLine.OncheckBillId, '+
'OnCheckBillLine.ItemCode, '+
'OnCheckBillLine.OnCheckBillLineNo, '+
'Item.ItemName, '+
'Uom.UomName, '+
'OnCheckBill.OnCheckBillNo, '+
'OncheckBill.VendorCode,'+
'OncheckBill.VendorCode+'' ''+v.VendorName Vendorflag,'+
'OnCheckBill.OnCheckDate, '+
'OnCheckBillLine.OnCheckQty, '+
'OnCheckBillLine.ReceivedQty,'+
'OnCheckBillLine.OnCheckStatus as OnCheckStatus, '+
'OnCheckBillLine.ReceivedQty as ReceivedQty, '+
'OnCheckBillLine.QcStatus as QcStatus, '+
'OnCheckBillLine.QcStatus as QcStatusbak, '+
'OnCheckBillLine.BatchNo,'+
'OnCheckBillLine.QcBatchNo,'+
'OnCheckBillLine.ReceivedQty as ReceivedQtybak, '+
'OnCheckBillLine.OnCheckRemArk as OnCheckRemArk,'+
'OnCheckBillLine.OnCheckRemArk as OnCheckRemArkbak '+
'from oncheckBillline '+
'join OnCheckBill '+
'on oncheckBill.OnCheckBillid=OnCheckBillLine.ONCheckBillId '+
'Join Item '+
'on Item.ItemCode=OnCheckBillLine.ItemCode '+
'JOin Uom '+
'on Uom.UomCode=Item.UomCode '+
'Join Vendor v '+
'On v.VendorCode=OncheckBill.VendorCode';
OrderByFields:='VendorCode,OnCheckDate,ItemCode';
Frm_Sys_Condition:=TFrm_Qc_Reclaim_C.Create(Application);
Act_Filter.Execute ;
// ConditionUserDefine:=' OnCheckBillLine.QcStatus=2';
// GetData;
end;
procedure TFrm_Qc_Reclaim.Act_CheckExecute(Sender: TObject);
begin
inherited;
if AdoQry_Main.State<>dsBrowse then
AdoQry_Main.Post;
AdoQry_Tmp.Connection.beginTrans;
try
with AdoQry_Main do
begin
First;
while not eof do
begin
if (fieldbyname('OncheckStatus').asinteger=0) and
(fieldbyname('ReceivedQty').asfloat<>0) then
begin
Process_Reclaim(fieldbyname('OncheckBillId').asstring,
fieldbyname('ItemCode').asstring,
fieldbyname('OnCheckBillLineNo').asstring,
fieldbyname('OnCheckRemArk').asstring,
fieldbyname('OnCheckQty').asfloat);
end;
Next;
end;
end;
except
AdoQry_Tmp.Connection.RollBackTrans;
DispInfo('保存失败!请稍候再试!',1);
abort;
end;
AdoQry_Tmp.Connection.CommitTrans;
DBGridEh.ReadOnly:=True;
Act_Check.Enabled:=False;
end;
procedure TFrm_Qc_Reclaim.AdoQry_MainBeforePost(DataSet: TDataSet);
begin
inherited;
if AdoQry_Main.fieldbyname('ReceivedQty').asFloat<0 then
begin
DispInfo('物料特别采用不能输入负数!',1);
Abort;
end;
if AdoQry_Main.fieldbyname('ReceivedQty').asFloat=0 then
begin
DispInfo('可采用物料数量为零!',3);
Abort;
end;
with AdoQry_Main do
begin
if fieldbyname('OnCheckStatus').asinteger=0 then
fieldbyname('QcStatus').asinteger:=6
else
fieldbyname('QcStatus').asinteger:=2;
If fieldbyname('ReceivedQty').AsFloat<>0 then
fieldbyname('OnCheckStatus').Asstring:='0';
If fieldbyname('ReceivedQty').asFloat>fieldbyname('OnCheckQty').asFloat then
begin
DispInfo('特采数量不能大于到货数量!',1);
fieldbyname('ReceivedQty').asFloat:=0;
fieldbyname('OnCheckStatus').Asstring:='1';
end;
end;
end;
procedure TFrm_Qc_Reclaim.FormActivate(Sender: TObject);
begin
inherited;
//Act_Check.Enabled:=False;
end;
procedure TFrm_Qc_Reclaim.AdoQry_MainAfterPost(DataSet: TDataSet);
begin
inherited;
//Act_Check.Enabled:=True;
end;
procedure TFrm_Qc_Reclaim.Process_Reclaim(id, ItemCode,LineNo,ReMArk: string;
Receivedqty: real);
var
whCode,WhPosition,pono,polineno:string;
begin
with AdoQry_Tmp do
begin
Close;
sql.text:='select whCode '+
' from OncheckBill'+
' where OncheckBillId='''+id+'''';
open;
whCode:=fieldbyname('whCode').asstring;
Close;
sql.text:='select WhPositionCode'+
' from WhPosition'+
' where whCode='''+whCode+''' and WhPositionType=1';
open;
WhPosition:=fieldbyname('WhPositionCode').asstring;
Close;
sql.text:='select Count(*) as kk from CurrentInv'+
' where whCode='''+whCode+''' and '+
' WhPositionCode='''+WhPosition+''' and '+
' ItemCode='''+ItemCode+'''';
open;
if fieldbyname('kk').AsInteger<=0 then
begin
Close;
sql.text:='insert CurrentInv(whCode,ItemCode,WhPositionCode) Values ('+
quotedstr(whCode)+','+quotedstr(ItemCode)+','+quotedstr(WhPosition)+')';
execsql;
end;
Close;
sql.text:='update CurrentInv'+
' set OnCheckInv=OnCheckInv+'+floattostr(Receivedqty)+
' where whCode='''+whCode+''' and '+
' WhPositionCode='''+WhPosition+''' and '+
' ItemCode='''+ItemCode+'''';
execsql;
Close;
sql.text:='update Item '+
' set CurrentOnCheckInv=CurrentOnCheckInv+'+floattostr(Receivedqty)+
' where ItemCode='''+ItemCode+'''';
execsql;
Close;
sql.text:='select B.pono,BL.polineno '+
' from OnCheckBill B,OncheckBillLine BL'+
' where B.OncheckBillId=BL.OncheckBillId and '+
' BL.OncheckBillId='''+id+''' and '+
' BL.OncheckBillLineNo='''+LineNo+'''';
open;
PONo:=fieldbyname('Pono').asstring;
POLineNO:=fieldbyname('POLineNo').asstring;
Close;
sql.text:='update Poline'+
' set PoInQty=PoInQty+'+floattostr(ReceivedQty)+
' where Pono='''+pono+''' and '+
' polineno='''+polineno+'''';
execsql;
Close;
sql.Text:='update OnCheckBillLine'+
' Set ReceivedQty='+AdoQry_Main.fieldbyname('ReceivedQty').asstring+','+
' QcStatus=6,'+
' SUseEmployeeCode='''+UserCode+''','+
' OnCheckStatus=0,'+
' OnCheckRemArk='''+ReMArk+''''+
' Where OnCheckBillId='''+id+''' '+
' and OnCheckBillLineNo='''+LineNO+'''';
execsql;
end;
end;
procedure TFrm_Qc_Reclaim.AdoQry_MainAfterScroll(DataSet: TDataSet);
begin
inherited;
AdoQry_Main.Cancel;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -