?? 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 + -