📄 inv_opoutsale_b.pas
字号:
refreshall;
end;
procedure TFrm_Inv_OpOutSale_B.set_OverPlan(flag: boolean);
begin
if flag then
begin
Act_Modify.Enabled:=False;
// Act_Modify.Visible:=False;
act_insertline.Visible:=True;
act_insertline.Enabled:=True;
Act_DeleteLine.Enabled:=True;
Act_DeleteLine.Visible:=True;
end
else
begin
Act_Modify.Enabled:=True;
Act_Modify.Visible:=True;
// act_insertline.Visible:=False;
// act_insertline.Enabled:=False;
// Act_DeleteLine.Enabled:=False;
// Act_DeleteLine.Visible:=False;
end;
end;
procedure TFrm_Inv_OpOutSale_B.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
inherited;
{ with AdoQry_Tmp2 do
begin
Close;
sql.text:='update po '+
' set poremArk='''+Edt_Memo.text+''' '+
' where pono='''+fpono+''' ';
execsql;
end;}
end;
procedure TFrm_Inv_OpOutSale_B.AdoQry_BodyBeforePost(DataSet: TDataSet);
var
a1,a2,a3:real;
begin
inherited;
if AdoQry_Body.fieldbyname('POoutQty').asstring='' then
begin
AdoQry_Body.fieldbyname('PoOutQty').asstring:='0';
Abort;
end;
if AdoQry_Body.fieldbyname('PoOutQty').asstring='0' then
begin
AdoQry_Body.fieldbyname('BatchNo').asstring:='';
Exit;
end;
if not InvQtyCheck
(False,
AdoQry_Body,
AdoQry_tmp,
getCode(Cmbx_WhCodeName.text),
getCode(Cmbx_Position.Text),
AdoQry_Body.fieldbyname('ItemCode').asstring,
'POoutQty',
AdoQry_Body.fieldbyname('poOutqty').asfloat,
False) then
begin
AdoQry_Body.Cancel;
abort;
end;
if BatchCtrl(AdoQry_Tmp,AdoQry_Body.fieldbyname('ItemCode').asstring) then
if Not BatchNoCheck(AdoQry_Tmp,AdoQry_Body.fieldbyname('BatchNo').asstring,
AdoQry_Body.fieldbyname('ItemCode').asstring,'',
Medt_Date.Text) then Abort;
if not IsOverPlan then
begin
a1:=AdoQry_Body.fieldbyname('POoutQty').asfloat;
a2:=min(
round(AdoQry_Body.fieldbyname('POCtrlQty').asfloat)-
(round(AdoQry_Body.fieldbyname('PORealQty').asfloat)),
AdoQry_Body.fieldbyname('UseableStore').asfloat);
if a1>a2 then
begin
DispInfo('本次领料数量不能大于未领料数量或可用库存!',1);
AdoQry_Body.Cancel;
abort;
end;
end;
a1:=AdoQry_Body.fieldbyname('POoutQty').asfloat;
a2:=abs(AdoQry_Body.fieldbyname('POoutQty').asfloat);
a3:=AdoQry_Body.fieldbyname('PoRealQty').asfloat;
if (a1<0) and (a2>a3)
then
begin
DispInfo('冲销数量不能大于累计领料数量!',1);
AdoQry_Body.Cancel;
abort;
end;
{ if not postflag then
begin
if checkrepeat then
begin
DispInfo('在同一张单据中不能出现相同物料!',1);
AdoQry_Body.Cancel;
abort;
end;
end;}
act_Save.Enabled :=True;
end;
procedure TFrm_Inv_OpOutSale_B.Act_PreviewExecute(Sender: TObject);
begin
//inherited;
BillPrint(AdoQry_Tmp.Connection,GetCode(Cmbx_WhCodeName.text),Edt_BillNo.text,'0202'{RecTypeCode},ModuleCode,True,False,True,'');
end;
procedure TFrm_Inv_OpOutSale_B.Act_PrintExecute(Sender: TObject);
begin
//inherited;
BillPrint(AdoQry_Tmp.Connection,GetCode(Cmbx_WhCodeName.text),Edt_BillNo.text,'0202'{RecTypeCode},ModuleCode,False,False,True,'');
end;
function TFrm_Inv_OpOutSale_B.CheckAllSame: boolean;
{var
I:integer;
Temp,Temp1:real;
begin
AdoQry_Body.First;
for i:=0 to AdoQry_Body.RecordCount-1 do
begin
if AdoQry_Body.fieldbyname('POOutQty').asfloat<>0 then
Temp1:=AdoQry_Body.fieldbyname('POOutQty').asfloat;
break;
end;
AdoQry_Body.First;
for i:=0 to AdoQry_Body.RecordCount-1 do
with AdoQry_Body do
begin
Temp:=Temp1*fieldbyname('POOutQty').asfloat;
if Temp<0 then
begin
Result:=False;
exit;
end;
// Temp:=Temp1;
next;
end;
Result:=True;
end;}
var
i:integer;
flag:boolean;
begin
AdoQry_Body.First;
for i:=0 to AdoQry_Body.RecordCount-1 do
begin
if AdoQry_Body.fieldbyname('POOutQty').asfloat<>0 then
begin
if AdoQry_Body.fieldbyname('POOutQty').asfloat>0 then
flag:=True
else flag:=False;
break;
end;
AdoQry_Body.next;
end;
AdoQry_Body.First;
for i:=0 to AdoQry_Body.RecordCount-1 do
begin
if AdoQry_Body.fieldbyname('POOutQty').asfloat<>0 then
begin
if ((flag) and (AdoQry_Body.fieldbyname('POOutQty').asfloat<0)) or
((not flag) and (AdoQry_Body.fieldbyname('POOutQty').asfloat>0)) then
begin
Result:=False;
exit;
end;
end;
AdoQry_Body.next;
end;
Result:=True;
end;
function TFrm_Inv_OpOutSale_B.CheckNotZero: boolean;
var
I:integer;
begin
AdoQry_Body.First;
for i:=0 to AdoQry_Body.RecordCount-1 do
begin
if AdoQry_Body.fieldbyname('POOutQty').asfloat<>0 then
begin
Result:=True;
exit;
end;
AdoQry_Body.next;
end;
Result:=False;
end;
procedure TFrm_Inv_OpOutSale_B.DisableAll(flag: boolean);
begin
Cmbx_WhCodeName.Enabled:=flag;
Cmbx_Position.Enabled:=flag;
// Edt_BillNo.Enabled:=flag;
// act_Save.Enabled:=flag;
Act_Modify.Enabled:=flag;
Medt_Date.Enabled:=flag;
Edt_Memo.Enabled:=flag;
DBGridEh.ReadOnly:=not flag;
end;
procedure TFrm_Inv_OpOutSale_B.refreshall;
var
tmpfields,tmpcustCode:string;
i:integer;
mypost:TDataSetNotifyEvent;
begin
mypost:=AdoQry_Body.BeforePost;
AdoQry_Body.BeforePost:=nil;
//刷新Query 及其它相关控件
With AdoQry_Body do
begin
tmpfields:=getInvfield(AdoQry_tmp,getCode(Cmbx_WhCodeName.text),getCode(Cmbx_Position.text),'CurrentInv');
tmpcustCode:=getCode(Lbl_VendorCodeName.Caption);
Close;
Sql.clear;
If IsOverPlan then
begin
Sql.Add('select '+
' op.pono,Op.PoLIneNo,Op.ItemCode, '+
' Item.ItemName,Uom.UomName, '+
' op.BilllineremArk BatchNo, '+
' Op.PoCtrlQty,Op.PoRealQty,op.POOutQty, '+
' SalePrice2.sp2Price,SalePrice2.sp2notaxPrice,'+
' c.'+tmpfields+' as UseableStore, '+
' op.ItemListId,'+
' op.BillLineRemArk, '+
' op.Ite_ItemCode,'+
' op.usestyle,'+
' op.BomQty,op.BomScrAp_Percent '+
'from OpItemList OP '+
' left join CurrentInv c '+
' on c.whCode='''+getCode(Cmbx_WhCodeName.text)+''''+
' and c.WhPositionCode='''+getCode(cmbx_Position.text)+''''+
' and c.ItemCode=op.ItemCode '+
' left join SalePrice2 on customerCode='+
quotedstr(tmpcustCode)+
' and SalePrice2.ItemCode=op.ItemCode '+
' and getdate() between SalePrice2.sp2stArtdate and SalePrice2.sp2enddate '+
'Join Item on Item.ItemCode=Op.ItemCode '+
'join Uom on Uom.UomCode=Item.UomCode '+
' join poline on poline.pono=op.pono and '+
' poline.polineno=op.polineno '+
' where round(op.PoCtrlQty,0)-(round(op.PoRealQty,0))<=0 '+
' and Op.PoNo='''+FPoNo+''' '+
' and poline.POLineStatus=6 '+
' and op.usestyle=1 '+
' and (Item.whCode='''+getCode(Cmbx_WhCodeName.text)+''' or '+
' c.'+tmpFields+'>0)'+
' Order by Op.PoLineNo');
// set_OverPlan(True);
end
Else
begin
Sql.Add('select '+
' op.pono,Op.PoLIneNo,Op.ItemCode, '+
' Item.ItemName,Uom.UomName, '+
' op.BilllineremArk BatchNo, '+
' op.ItemListId,'+
' op.usestyle,'+
' Op.PoCtrlQty,Op.PoRealQty,Op.POOutQty, '+
' SalePrice2.sp2Price,SalePrice2.sp2notaxPrice,'+
' case when c.'+tmpfields+' is Null then 0 else '+
' c.'+tmpfields+' end as UseableStore,op.BillLineRemArk,op.ite_ItemCode,'+
' op.BomQty,op.BomScrAp_Percent '+
'from OpItemList OP '+
' left join CurrentInv c '+
' on c.whCode='''+getCode(Cmbx_WhCodeName.text)+''''+
' and c.WhPositionCode='''+getCode(cmbx_Position.text)+''''+
' and c.ItemCode=op.ItemCode '+
' left join SalePrice2 on customerCode='+
quotedstr(tmpcustCode)+
' and SalePrice2.ItemCode=op.ItemCode '+
' and getdate() between SalePrice2.sp2stArtdate and SalePrice2.sp2enddate '+
'Join Item on Item.ItemCode=Op.ItemCode '+
//'Item.whCode='''+getCode(Cmbx_WhCodeName.text)+''' '+
'join Uom on Uom.UomCode=Item.UomCode '+
' join poline on poline.pono=op.pono and '+
' poline.polineno=op.polineno '+
' where poline.POLineStatus=6 and '+
' Op.PoNo='''+FPoNo+''' and '+
' op.usestyle=1 and '+
//' and Op.PoCtrlQty>0 '+
' round(op.PoCtrlQty,0)-(round(op.PoRealQty,0))>=0 and '+
' (Item.whCode='''+getCode(Cmbx_WhCodeName.text)+''' or '+
' C.'+tmpfields+'>0)'+
' Order by Op.PoLineNo');
// set_OverPlan(False);
end;
Open;
for i:=0 to recordCount-1 do
begin
edit;
fieldbyname('BatchNo').asstring:='';
fieldbyname('POOutQty').asfloat:=0;
fieldbyname('PoCtrlQty').asfloat:=round(fieldbyname('PoCtrlQty').asfloat);
post;
next;
end;
First;
end;
AdoQry_Body.BeforePost:=mypost;
//act_Save.Enabled:=False;
end;
procedure TFrm_Inv_OpOutSale_B.Act_autoExecute(Sender: TObject);
var
i:integer;
mypost:TDataSetNotifyEvent;
Tmp_var:Double;
BatchNo:String;
begin
mypost:=AdoQry_Body.BeforePost;
AdoQry_Body.BeforePost:=nil;
AdoQry_Body.First;
with AdoQry_Body do
for i:=0 to recordCount-1 do
begin
Tmp_var:=
min(round(fieldbyname('PoCtrlQty').asfloat)-round(fieldbyname('PoRealQty').asfloat),
fieldbyname('UseableStore').asfloat);
if BatchCtrl(AdoQry_Tmp,fieldbyname('ItemCode').asString) then
begin
BatchNo:=GiveBatchNo(AdoQry_Tmp,getCode(Cmbx_WhCodeName.text),
getCode(Cmbx_Position.text),fieldbyname('ItemCode').asString,
Medt_Date.text,Tmp_var);
if BatchNo='' then
begin
next;
continue;
end
end;
edit;
fieldbyname('BatchNo').asString:=BatchNo;
fieldbyname('PooutQty').asfloat:=Tmp_var;
if fieldbyname('PooutQty').asfloat<0 then fieldbyname('PooutQty').asfloat:=0;
post;
next;
end;
AdoQry_Body.First;
DBGridEh.Refresh;
act_Save.Enabled:=True;
AdoQry_Body.BeforePost:=mypost;
end;
function TFrm_Inv_OpOutSale_B.InitwhposIfSpec:integer;
var
i:integer;
Str:string;
Ado_tmp:TAdoQuery;
begin
if IsSpecial then
begin
Ado_tmp:=TAdoQuery.Create(nil);
Ado_tmp.Connection:=AdoQry_Body.Connection;
Ado_tmp.SQL.text:='select WhPositionCode '+
' from WhPosition '+
' where WHCode='''+getCode(Cmbx_WhCodeName.Text)+''' and '+
' WhPositionType=2';
Ado_tmp.Open;
Str:=Ado_tmp.fieldbyname('WhPositionCode').asstring;
For i:=0 to Cmbx_Position.Items.Count-1 do
if getCode(Cmbx_Position.Items[i])=Trim(str) then
begin
Result:=i;
exit;
end;
end
else Result:=0;
end;
procedure TFrm_Inv_OpOutSale_B.DBGridEhKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
BatchStr:string;
i:integer;
begin
inherited;
If Word(Key)=VK_F9 then
with AdoQry_Body do
begin
BatchStr:=BatchHint(AdoQry_Tmp.Connection,fieldbyname('ItemCode').asstring,
'',getCode(Cmbx_WhCodeName.text),getCode(Cmbx_Position.Text));
if BatchStr<>'' then
begin
if not BatchInvCheck(AdoQry_Tmp,BatchStr,'c',
getCode(Cmbx_WhCodeName.text),
getCode(Cmbx_Position.text),
fieldbyname('POOutQty').asFloat) then Abort;
edit;
fieldbyname('BatchNo').asstring:=BatchStr;
post;
end;
end;
end;
procedure TFrm_Inv_OpOutSale_B.DBGridEhEnter(Sender: TObject);
begin
Medt_DateExit(sender);
inherited;
end;
procedure TFrm_Inv_OpOutSale_B.AdoQry_BodyCalcFields(DataSet: TDataSet);
begin
inherited;
AdoQry_Body.fieldbyname('sp2notaxPrice').Value:=
AdoQry_Body.fieldbyname('sp2Price').Value*100/(100+StrToInt(lbl_taxpercent.Caption));
AdoQry_BodytaxAmount.Value:=AdoQry_BodyPOOutQty.Value*AdoQry_Bodysp2Price.Value;
AdoQry_BodynotaxAmount.Value:=AdoQry_BodyPOOutQty.Value*AdoQry_Bodysp2notaxPrice.Value;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -