📄 acp510_02.pas.svn-base
字号:
if not (ADataSet.State in [dsInsert,dsEdit]) then
if (ADataSet.IsEmpty) or (AType='ADD') then ADataSet.Append else ADataSet.Edit;
ADataSet.FieldByName('FItemID').Value:=AItemInfo.ItemID;
ADataSet.FieldByName('FItemName').Value:=AItemInfo.ItemName;
ADataSet.FieldByName('FItemSpec').Value:=AItemInfo.ItemSpec;
ADataSet.FieldByName('FUnitName').Value:=AItemInfo.UnitName;
ADataSet.FieldByName('FOrderQty').Value:=AOrderInfo.OrderQty;
ADataSet.FieldByName('FOrderPrice').Value:=APriceInfo.StdPrice;
ADataSet.FieldByName('FOrderAmount').Value:=APriceInfo.OrderAmt;
ADataSet.FieldByName('FDisAmt').Value:=APriceInfo.DisAmt;
ADataSet.FieldByName('FItemNo').Value:=AItemInfo.ItemNo;
ADataSet.FieldByName('FOrder').Value:=AItemInfo.OrderNo;
ADataSet.FieldByName('FLineNo').Value:=AItemInfo.LineNo;
ADataSet.FieldByName('FQty').Value:=ADataSet.FieldByName('FOrderQty').Value;
ADataSet.FieldByName('FAmount').Value:=ADataSet.FieldByName('FOrderAmount').Value-APriceInfo.DisAmt;
ADataSet.FieldByName('FPrice').Value:=ADataSet.FieldByName('FAmount').Value/ADataSet.FieldByName('FQty').Value;
ADataSet.FieldByName('FTaxRate').Value:=APriceInfo.TaxRate;
ADataSet.FieldByName('FTaxAmt').Value:=APriceInfo.TaxAmount;
ADataSet.FieldByName('FInvAmount').Value:=AOrderInfo.InvAmount;
ADataSet.FieldByName('FAcpAmt').Value:=ADataSet.FieldByName('FAmount').Value+ADataSet.FieldByName('FTaxAmt').Value;
if AType='UPD' then Exit;
ADataSet.Post;
end;
procedure TAcp510_02Form.adsAcp510BNewRecord(DataSet: TDataSet);
begin
inherited;
//设定行的初始值
ALastNo:=ALastNo+1;
adsAcp510BFNo.Value:=ALastNo;
end;
procedure TAcp510_02Form.cbCurrChange(Sender: TObject);
begin
inherited;
qryGld100.Locate('G100_003',cbCurr.Text,[]);
edtRate.Text:=qryGld100.FieldByName('G100_005').AsString;
adsAcp510B.Close;
adsAcp510B.CreateDataSet;
AIsChanged:=True;
wwDBGrid1UpdateFooter(wwDBGrid1);
end;
procedure TAcp510_02Form.wwDBGrid1ColExit(Sender: TObject);
begin
inherited;
if wwDBGrid1.GetActiveField.FieldName='FQty' then
begin
SetQty;
end else
if wwDBGrid1.GetActiveField.FieldName='FPrice' then
begin
SetPrice;
end;
if wwDBGrid1.GetActiveField.FieldName='FAmount' then
begin
SetAmount;
end;
if wwDBGrid1.GetActiveField.FieldName='FOrderQty' then
begin
SetDefault;
end;
if wwDBGrid1.GetActiveField.FieldName='FTaxRate' then
begin
SetTaxRate;
end;
end;
procedure TAcp510_02Form.SetPrice;
begin
if adsAcp510BFPrice.AsFloat>adsAcp510BFOrderPrice.AsFloat then
begin
ShowMsg('UMS10000687'); //发票单价不能大于采购单价,请重新输入
Exit;
end else
begin
if not (adsAcp510B.State in [dsInsert,dsEdit]) then Exit;
wwDBGrid1.ColumnByName('FAmount').ReadOnly:=False;
wwDBGrid1.ColumnByName('FTaxAmt').ReadOnly:=False;
wwDBGrid1.ColumnByName('FAcpAmt').ReadOnly:=False;
adsAcp510BFAmount.Value:=adsAcp510BFQty.Value*adsAcp510BFPrice.Value;
adsAcp510BFTaxAmt.Value:=adsAcp510BFAmount.Value*adsAcp510BFTaxRate.Value;
adsAcp510BFAcpAmt.Value:=adsAcp510BFAmount.Value+adsAcp510BFTaxAmt.Value;
wwDBGrid1.ColumnByName('FTaxAmt').ReadOnly:=True;
wwDBGrid1.ColumnByName('FAcpAmt').ReadOnly:=True;
end;
end;
procedure TAcp510_02Form.SetQty;
begin
if adsAcp510BFQty.AsFloat>adsAcp510BFOrderQty.AsFloat then
begin
ShowMsg('UMS10000688'); //发票数量不能大于采购数量,请重新输入
Exit;
end else
begin
if not (adsAcp510B.State in [dsInsert,dsEdit]) then Exit;
wwDBGrid1.ColumnByName('FAmount').ReadOnly:=False;
wwDBGrid1.ColumnByName('FTaxAmt').ReadOnly:=False;
wwDBGrid1.ColumnByName('FAcpAmt').ReadOnly:=False;
adsAcp510BFAmount.Value:=adsAcp510BFQty.Value*adsAcp510BFPrice.Value;
adsAcp510BFTaxAmt.Value:=adsAcp510BFAmount.Value*adsAcp510BFTaxRate.Value;
adsAcp510BFAcpAmt.Value:=adsAcp510BFAmount.Value+adsAcp510BFTaxAmt.Value;
adsAcp510BFTaxAmt.ReadOnly:=True;
adsAcp510BFAcpAmt.ReadOnly:=True;
wwDBGrid1.ColumnByName('FTaxAmt').ReadOnly:=True;
wwDBGrid1.ColumnByName('FAcpAmt').ReadOnly:=True;
end;
end;
procedure TAcp510_02Form.wwDBGrid1Enter(Sender: TObject);
begin
inherited;
OnKeyDown:=nil;
end;
procedure TAcp510_02Form.wwDBGrid1Exit(Sender: TObject);
begin
inherited;
OnKeyDown:=AKeyEvent;
end;
procedure TAcp510_02Form.SetDefault;
begin
//
end;
procedure TAcp510_02Form.wwDBGrid1UpdateFooter(Sender: TObject);
var
AAmount,ATaxAmt,AAcpAmt:Double;
begin
inherited;
//发票金额 FAmount 发票税额 FTaxAmt 应收金额 FAcpAmt
if not AIsChanged then Exit;
AAmount:=0;
ATaxAmt:=0;
AAcpAmt:=0;
ADODataSet1.Clone(adsAcp510B);
ADODataSet1.DisableControls;
ADODataSet1.First;
while not ADODataSet1.Eof do
begin
AAmount:=AAmount+StrToFloatA(FloatToStrF(ADODataSet1.FieldByName('FAmount').AsFloat,ffNumber,18,2));
ATaxAmt:=ATaxAmt+StrToFloatA(FloatToStrF(ADODataSet1.FieldByName('FTaxAmt').AsFloat,ffNumber,18,2));
AAcpAmt:=AAcpAmt+StrToFloatA(FloatToStrF(ADODataSet1.FieldByName('FAcpAmt').AsFloat,ffNumber,18,2));
ADODataSet1.Next;
end;
ADODataSet1.EnableControls;
wwDBGrid1.ColumnByName('FItemID').FooterValue:=GetDBString('COM00004002')+FloatToStrF(ADODataSet1.RecordCount,ffNumber,18,0); //记录总数
wwDBGrid1.ColumnByName('FAmount').FooterValue:=FloatToStrF(AAmount,ffNumber,18,2);
wwDBGrid1.ColumnByName('FTaxAmt').FooterValue:=FloatToStrF(ATaxAmt,ffNumber,18,2);
wwDBGrid1.ColumnByName('FAcpAmt').FooterValue:=FloatToStrF(AAcpAmt,ffNumber,18,2);
edtAmount.Text:=FloatToStrF(AAmount,ffNumber,18,2);
edtRevenue.Text:=FloatToStrF(ATaxAmt,ffNumber,18,2);
edtReceive.Text:=FloatToStrF(AAcpAmt,ffNumber,18,2);
end;
procedure TAcp510_02Form.SetDBGridA;
var
I:Integer;
begin
for I:=0 to wwDBGrid1.Selected.Count-1 do
begin
wwDBGrid1.Columns[I].ReadOnly:=True;
end;
wwDBGrid1.ColumnByName('FQty').ReadOnly:=False;
wwDBGrid1.ColumnByName('FPrice').ReadOnly:=False;
wwDBGrid1.ColumnByName('FTaxRate').ReadOnly:=False;
wwDBGrid1.ColumnByName('FRemark').ReadOnly:=False;
wwDBGrid1.Refresh;
end;
procedure TAcp510_02Form.edtCustExit(Sender: TObject);
begin
inherited;
//客户编号
if trim(edtCust.Text)='' then Exit;
if qryOrd150.Locate('O150_002',edtCust.Text,[]) then
begin
GetCustPlaceInfo;
end else
begin
ShowMsg('UMS10000689'); //输入的客户编号无效,请重新输入
edtCustName.Text:='';
edtPhone.Text:='';
edtAddress.Text:='';
edtContact.Text:='';
edtCust.SetFocus;
adsAcp510B.Close;
adsAcp510B.CreateDataSet;
Abort;
end;
end;
procedure TAcp510_02Form.Action1Execute(Sender: TObject);
begin
inherited;
//取消
if ADOQuery1.IsEmpty then
begin
ShowMsg('UMS10000690'); //表记录为空,操作无效
Abort;
end;
if not (ADOQuery1A510A_003.Value in [0]) then
begin
ShowMsg('UMS10000691'); //仅新增状态的采购发票可以作废
Abort;
end;
ADOQuery1.Edit;
ADOQuery1A510A_003.Value:=1;
ADOQuery1.Post;
ActRefresh.Execute;
ShowMsg('UMS10000692'); //采购发票状态已成功设置为作废状态
end;
procedure TAcp510_02Form.SetAmount;
begin
if adsAcp510BFAmount.AsFloat>adsAcp510BFOrderAmount.Value-adsAcp510BFDisAmt.Value then
begin
ShowMsg('UMS10000693'); //发票金额不能大于采购金额和折扣金额之差采购单价,请重新输入
Exit;
end else
begin
if not (adsAcp510B.State in [dsInsert,dsEdit]) then Exit;
wwDBGrid1.ColumnByName('FPrice').ReadOnly:=False;
wwDBGrid1.ColumnByName('FQty').ReadOnly:=False;
wwDBGrid1.ColumnByName('FTaxAmt').ReadOnly:=False;
wwDBGrid1.ColumnByName('FAcpAmt').ReadOnly:=False;
adsAcp510BFPrice.Value:=adsAcp510BFOrderPrice.Value;
adsAcp510BFQty.Value:=adsAcp510BFOrderAmount.Value/adsAcp510BFPrice.Value;
adsAcp510BFTaxAmt.Value:=adsAcp510BFAmount.Value*adsAcp510BFTaxRate.Value;
adsAcp510BFAcpAmt.Value:=adsAcp510BFAmount.Value+adsAcp510BFTaxAmt.Value;
wwDBGrid1.ColumnByName('FAcpAmt').ReadOnly:=True;
end;
end;
procedure TAcp510_02Form.SetTaxRate;
begin
if not (adsAcp510B.State in [dsInsert,dsEdit]) then Exit;
wwDBGrid1.ColumnByName('FTaxAmt').ReadOnly:=False;
wwDBGrid1.ColumnByName('FAcpAmt').ReadOnly:=False;
adsAcp510BFTaxAmt.Value:=adsAcp510BFAmount.Value*adsAcp510BFTaxRate.Value;
adsAcp510BFAcpAmt.Value:=adsAcp510BFTaxAmt.Value+adsAcp510BFAmount.Value;
wwDBGrid1.ColumnByName('FTaxAmt').ReadOnly:=True;
wwDBGrid1.ColumnByName('FAcpAmt').ReadOnly:=True;
end;
procedure TAcp510_02Form.mmiAddClick(Sender: TObject);
var
ADataSet:TADODataSet;
begin
inherited;
//新增
ADataSet:=adsAcp510B;
ADataSet.Append;
end;
procedure TAcp510_02Form.mmiEditClick(Sender: TObject);
var
ADataSet:TADODataSet;
begin
inherited;
//修改
ADataSet:=adsAcp510B;
if ADataSet.IsEmpty then
begin
ShowMsg('UMS10000002'); //表记录为空,操作无效
Abort;
end;
ADataSet.Edit;
end;
procedure TAcp510_02Form.mmiDelClick(Sender: TObject);
var
ADataSet:TADODataSet;
begin
inherited;
//删除
ADataSet:=adsAcp510B;
if ADataSet.IsEmpty then
begin
ShowMsg('UMS10000002'); //表记录为空,操作无效
Abort;
end;
if ShowDialog('UMS10000008')=IDNO then Abort; //确定要删除此记录吗?
ADataSet.Delete;
AIsChanged:=True;
wwDBGrid1UpdateFooter(wwDBGrid1);
end;
procedure TAcp510_02Form.pmAcp510BPopup(Sender: TObject);
var
I:Integer;
begin
inherited;
for I:=0 to pmAcp510B.Items.Count-1 do
begin
pmAcp510B.Items.Items[I].Enabled:=ActSave.Enabled;
end;
end;
initialization
RegisterClass(TAcp510_02Form);
finalization
UnRegisterClass(TAcp510_02Form);
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -