📄 inv_opout_b.pas
字号:
AdoQry_Tmp.ExecSql;
Scll(AdoQry_tmp,fieldbyname('ItemCode').asstring,'POScLL',fieldbyname('PONO').AsString,fieldbyname('POLINENO').asinteger);
end
Else
begin
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.clear;
AdoQry_Tmp.SQL.Add('Update OpItemList Set'+
' PoRealQty=PoRealQty+'+fieldbyname('POOutQty').AsString+','+
' BillLineRemArk='''+AdoQry_Body.fieldbyname('BillLineRemArk').asstring+''' '+
'Where ItemListId='+inttostr(ItemListId));
AdoQry_Tmp.ExecSql;
Scll(AdoQry_tmp,fieldbyname('ItemCode').asstring,'POScLL',fieldbyname('PONO').AsString,fieldbyname('POLINENO').asinteger);
end;
//计算供应商移动加权平均价
//正常领料
if True then//NeedChangePrice then
begin
If (fieldbyname('PoOutQty').AsFloat>0) or (PriceType=1) then
begin
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.clear;
AdoQry_Tmp.SQL.Add('Select Count(*) as RecCount from OPAveragePrice'+
' Where VendorCode='''+GetCode(Lbl_VendorCodeName.Caption)+''''+
' and ItemCode='''+fieldbyname('ItemCode').AsString+'''');
AdoQry_Tmp.OPen;
If AdoQry_Tmp.fieldbyname('RecCount').AsInteger<=0 then
begin
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.clear;
AdoQry_Tmp.SQL.Add('Insert OPAveragePrice'+
'(VendorCode,'+
'ItemCode,'+
'OPApQty,'+
'OPApAmount)'+
'select '''+GetCode(Lbl_VendorCodeName.Caption)+''','+
''''+fieldbyname('ItemCode').AsString+''','+
fieldbyname('PoOutQty').AsString+','+
'Round('+fieldbyname('POOutQty').asstring+
'*'+floattostr(Price)+',2)');
AdoQry_Tmp.ExecSql;
end
Else
begin
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.clear;
AdoQry_Tmp.SQL.Add('UpDate OpAveragePrice Set '+
' OpApQty=OpApQty+'+fieldbyname('PoOutQty').AsString+','+
' OpApAmount=OpApAmount'+
'+Round('+fieldbyname('POOutQty').asstring+
'*'+floattostr(Price)+',2) '+
'Where ItemCode='''+fieldbyname('ItemCode').AsString+''''+
' and VendorCode='''+GetCode(Lbl_VendorCodeName.Caption)+'''');
AdoQry_Tmp.ExecSql;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.clear;
AdoQry_Tmp.SQL.Add('UpDate OpAveragePrice Set '+
' OpAveragePrice=Case '+
'OpApQty When '+
'0 then OpAveragePrice '+//modify by 2001.06.24
'Else OpApAmount/opApqty '+
'end Where ItemCode='''+fieldbyname('ItemCode').AsString+''''+
' and VendorCode='''+GetCode(Lbl_VendorCodeName.Caption)+'''');
AdoQry_Tmp.ExecSql;
end;
end
Else
//委外退料
begin
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.clear;
AdoQry_Tmp.SQL.Add('UpDate OpAveragePrice Set '+
' OpApQty=OpApQty+'+fieldbyname('PoOutQty').AsString+','+
' OpApAmount=case when opApqty=0 then 0 else '+
'Round((OpApAmount/OpApqty)*(OPApQty+'+
fieldbyname('PoOutQty').AsString+'),2) end '+
'Where ItemCode='''+fieldbyname('ItemCode').AsString+''''+
' and VendorCode='''+GetCode(Lbl_VendorCodeName.Caption)+'''');
AdoQry_Tmp.ExecSQL;
end;
end;
next;
end;
end;
AdoQry_Tmp.Connection.CommitTrans;
AdoQry_Body.EnableControls;
dbgrideh.ReadOnly:=True;
Edt_Memo.Enabled:=False;
Medt_Date.Enabled:=False;
Edt_BillNo.text:=BillNo;
act_Save.Enabled:=False;
act_auto.enabled:=False;
act_insertline.enabled:=False;
act_Deleteline.enabled:=False;
disableall(False);
except
AdoQry_Tmp.Connection.RollBackTrans;
AdoQry_Body.EnableControls;
if not BeforeSaveError then
DispInfo(' 单据保存失败,请稍后再试! ',1);
end;
end;
procedure TFrm_Inv_OpOut_B.Cmbx_WhCodeNameChange(Sender: TObject);
var
tmpfields:string;
begin
inherited;
InitCmbx_WhPosition(GetCode(Cmbx_WhCodeName.Text));
Cmbx_Position.ItemIndex:=InitwhposIfSpec;
refreshall;
end;
procedure TFrm_Inv_OpOut_B.Cmbx_WhCodeNameExit(Sender: TObject);
begin
inherited;
If Cmbx_WhCodeName.Text='' then
begin
DispInfo('请选择一个仓库!',1);
Abort;
end;
end;
procedure TFrm_Inv_OpOut_B.Cmbx_PositionExit(Sender: TObject);
begin
inherited;
If Cmbx_Position.Text='' then
begin
DispInfo('请选择一个货位',1);
Cmbx_Position.SetFocus;
abort;
end;
end;
procedure TFrm_Inv_OpOut_B.Medt_DateExit(Sender: TObject);
begin
inherited;
if not WHClsPeriodCheck(AdoQry_Tmp,GetCode(Cmbx_WhCodeName.Text),Copy((Medt_Date.Text),1,7)) then
begin
Medt_Date.SetFocus;
act_Save.Enabled :=False;
abort;
end
else if CheckNotZero then
begin
act_Save.Enabled :=True;
end;
end;
procedure TFrm_Inv_OpOut_B.FormCreate(Sender: TObject);
begin
inherited;
Frm_Entry_Detail:=TFrm_Inv_OpOut_D.Create(Self);
end;
procedure TFrm_Inv_OpOut_B.FormActivate(Sender: TObject);
var
ishave:boolean;
begin
inherited;
ishave:=False;
AdoQry_Body.DisableControls ;
AdoQry_Body.First ;
with AdoQry_Body do
begin
while not eof do
begin
if fieldbyname('usestyle').asinteger=0 then
ishave:=True;
next;
end;
end;
if AdoQry_Body.RecordCount=0 then
ishave:=True;
act_Save.Enabled:=ishave;
AdoQry_Body.First ;
AdoQry_Body.EnableControls ;
// ToolButton7.Action:=act_Check;
// ToolButton4.left:=TlBtn_Print.left+ToolButton4.Width;
//跟据超订单标志进行初始化
If IsOverPlan then
begin
Caption:='委外加工超订单领料';
Pnl_Title.Caption:='委外加工超订单领料';
act_insertline.Visible:=True;
act_Deleteline.Visible:=True;
act_auto.Visible:=False;
end
Else
begin
Caption:='委外加工领料';
Pnl_Title.Caption:='委外加工领料';
act_insertline.Visible:=False;
act_Deleteline.Visible:=False;
act_auto.Visible:=True;
end;
if (Addormodify) and (isOverPlan) then
begin
act_insertline.Enabled:=True;
act_Deleteline.Enabled:=True;
act_Save.visible:=True;
DBGridEh.ReadOnly:=False;
DBGridEh.Columns[0].ReadOnly:=True;
DBGridEh.Columns[1].ReadOnly:=True;
DBGridEh.Columns[2].ReadOnly:=True;
DBGridEh.Columns[3].ReadOnly:=True;
DBGridEh.Columns[4].ReadOnly:=True;
DBGridEh.Columns[5].ReadOnly:=True;
DBGridEh.Columns[6].ReadOnly:=True;
DBGridEh.Columns[7].ReadOnly:=False;
DBGridEh.Columns[8].ReadOnly:=True;
DBGridEh.Columns[9].ReadOnly:=True;
DBGridEh.Columns[10].ReadOnly:=True;
DBGridEh.Columns[11].ReadOnly:=True;
end
else if (isOverPlan) and (not Addormodify) then
begin
act_insertline.Enabled:=False;
act_Deleteline.Enabled:=False;
DBGridEh.ReadOnly:=True;
end
else if (not isOverPlan) and (Addormodify) then
begin
act_auto.Enabled:=True;
DBGridEh.ReadOnly:=False;
DBGridEh.Columns[0].ReadOnly:=True;
DBGridEh.Columns[1].ReadOnly:=True;
DBGridEh.Columns[2].ReadOnly:=True;
DBGridEh.Columns[3].ReadOnly:=True;
DBGridEh.Columns[4].ReadOnly:=True;
DBGridEh.Columns[5].ReadOnly:=True;
DBGridEh.Columns[6].ReadOnly:=True;
DBGridEh.Columns[7].ReadOnly:=False;
DBGridEh.Columns[8].ReadOnly:=False;
DBGridEh.Columns[9].ReadOnly:=True;
DBGridEh.Columns[10].ReadOnly:=True;
DBGridEh.Columns[10].ReadOnly:=True;
end
else if (not isOverPlan) and (not Addormodify) then
begin
DBGridEh.ReadOnly:=True;
act_auto.Enabled:=False;
end;
end;
procedure TFrm_Inv_OpOut_B.Act_SaveExecute(Sender: TObject);
begin
//跟据超订单标志进行数据存盘
if CheckNotZero then
begin
//inherited;
If IsOverPlan then
begin
Caption:='委外加工超订单领料';
Pnl_Title.Caption:='委外加工超订单领料';
end
Else
begin
Caption:='委外加工领料';
Pnl_Title.Caption:='委外加工领料';
Act_DeleteLine.Enabled:=False;
Act_InsertLine.Enabled:=False;
end;
end
else
begin
DispInfo('出库均为零,不能保存!',3);
act_Save.Enabled:=False;
exit;
end;
savedata;
end;
procedure TFrm_Inv_OpOut_B.Cmbx_PositionChange(Sender: TObject);
begin
inherited;
//act_Save.enabled:=True;
refreshall;
end;
procedure TFrm_Inv_OpOut_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_OpOut_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_OpOut_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;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -