?? pcedpurchasecloth.pas
字號:
TBaseVoucherReport(Result).SetMasterDataSet(MasterDataSet);
end;
procedure TPCEDPurchaseClothForm.adsDetailGoalQuantityChange(Sender: TField);
begin
adsDetail.Edit;
adsDetail.FieldByName('Amount').AsFloat :=
adsDetail.fieldbyname('GoalQuantity').AsFloat*adsDetail.fieldbyname('PriceGoal').AsFloat;
adsDetail.Edit;
adsDetail.FieldByName('Quantity').AsFloat :=adsDetail.fieldbyname('GoalQuantity').AsFloat;
adsDetail.Edit;
adsDetail.FieldByName('PriceBase').AsFloat :=adsDetail.fieldbyname('PriceGoal').AsFloat;
end;
procedure TPCEDPurchaseClothForm.FilePrintActionExecute(Sender: TObject);
function CurrencyUpperCaseHitch(Value: Currency): string;
function OnesPlace(X: Double): Integer;
begin
Result := Trunc(X);
Result := Result - Result div 10 * 10;
end;
var
I, N: Integer;
S: string;
begin
Result := '';
Value := Round(Value * Power(10, 2)) / Power(10, 2);
for I := 7 downto 0 do
begin
N := OnesPlace(Value / Power(10, I - 2));
S := NumberToHZ(N, 1);
if S = '' then S := '零';
if Result = '' then Result := S
else Result := Result + ' ' + S;
end;
end;
var
ExePath: string;
S1, S2, S3, S4, S5, S6, S7: string;
begin
inherited;
ExePath := ExtractFilePath(Application.ExeName);
with DetailDataSet do
begin
First;
while not Eof do
begin
S1 := S1 + #13#10 + FieldByName('GoodsName').DisplayText;
S2 := S2 + #13#10 + FieldByName('GoodsSpec').DisplayText;
S3 := S3 + #13#10 + FieldByName('GoalUnit').DisplayText;
S4 := S4 + #13#10 + FieldByName('GoalQuantity').DisplayText;
S5 := S5 + #13#10 + FieldByName('PriceGoal').DisplayText;
S6 := S6 + #13#10 + FieldByName('Amount').DisplayText;
S7 := S7 + #13#10 + FieldByName('Memo').DisplayText;
Next;
end;
end;
with TReportRuntime.Create(Self) do
begin
ReportFile := ExePath + 'Reports\Sale.ept';
SetDataSet('Master', MasterDataSet);
SetDataSet('Detail', DetailDataSet);
SetVarValue('S1', S1);
SetVarValue('S2', S2);
SetVarValue('S3', S3);
SetVarValue('S4', S4);
SetVarValue('S5', S5);
SetVarValue('S6', S6);
SetVarValue('S7', S7);
SetVarValue('QuantityTotal', CurrToStrF(DBGrid.AggregateList.Aggregates.FindAggregate(atSum, 'GoalQuantity').AggregateValue, ffFixed, 2));
SetVarValue('AmountTotal', CurrToStrF(DBGrid.AggregateList.Aggregates.FindAggregate(atSum, 'Amount').AggregateValue, ffCurrency, 2));
SetVarValue('AmountTotalHZ', CurrencyUpperCaseHitch(DBGrid.AggregateList.Aggregates.FindAggregate(atSum, 'Amount').AggregateValue));
PrintPreview(True);
end;
end;
procedure TPCEDPurchaseClothForm.adsDetailPackUnitIDChange(Sender: TField);
var ExChRate :real;
begin
end;
procedure TPCEDPurchaseClothForm.NoCreditSaleClick(Sender: TObject);
begin
if NoCreditSale.Checked then
begin
adsMaster.Edit;
if pos(Trim(NoCreditSale.Caption),Trim(adsMaster.FieldByName('Memo').AsString))<=0 then
adsMaster.FieldByName('Memo').AsString :=
Copy( Trim(NoCreditSale.Caption)+Trim(adsMaster.FieldByName('Memo').AsString),1,60);
adsMaster.FieldByName('BillMode').AsString :='現款采購';
RemarkDBEdit.ReadOnly :=True;
end else
begin
adsMaster.Edit;
if pos(Trim(NoCreditSale.Caption),Trim(adsMaster.FieldByName('Memo').AsString))>0 then
adsMaster.FieldByName('Memo').AsString :=
StringReplace( Trim(adsMaster.FieldByName('Memo').AsString) ,
Trim(NoCreditSale.Caption),'',[rfReplaceAll, rfIgnoreCase]);
adsMaster.FieldByName('BillMode').AsString :='采購開單';
RemarkDBEdit.ReadOnly :=False;
end;
DBEdit6.ReadOnly :=not NoCreditSale.Checked;
if DBEdit6.ReadOnly then
begin
adsMaster.Edit;
adsMaster.FieldByName('CashDiscount').Value :=null;
end;
end;
procedure TPCEDPurchaseClothForm.DBEdit6Enter(Sender: TObject);
begin
DBEdit6.ReadOnly :=not NoCreditSale.Checked;
if DBEdit6.ReadOnly then
begin
adsMaster.Edit;
adsMaster.FieldByName('CashDiscount').Value :=null;
end;
end;
procedure TPCEDPurchaseClothForm.InternalSave;
var adoTemp: TADOQuery;
code,AccountIDStr,MasterIDStr,IDStr:string;
MasterID:Integer;
begin
inherited;
if (adsMaster.fieldbyname('ID').AsInteger=0) or
(adsMaster.fieldbyname('ID').IsNull) then exit;
adoTemp := TADOQuery.Create(nil);
adoTemp.Connection := CommonData.acnConnection;
with adoTemp do
begin
//--------------判斷將要插入的記錄是否已經正在于PCGoodsInMaster,不存在就插入
Close;
sql.Text :=' select b.ID from PCPurchaseDetail a '
+' left outer join PCPurchaseMaster b on a.MasterID=b.ID '
+' where isnull(a.goodsId,0)<>0 '
+' and isnull(a.GoalQuantity,0)<>0 '
+' and b.id=' + adsMaster.fieldbyname('ID').AsString
+' and b.RecordState<>' + QuotedStr('刪除')
+' and b.ID not in '
+' (select top 1 OriginID from PCGoodsInMaster where '
+' OriginTable='+ QuotedStr('PCPurchaseMaster')
+' and OriginID='+adsMaster.fieldbyname('ID').AsString+' )';
open;
if not adoTemp.IsEmpty then //判斷完畢,開始插入
begin
code :=GetMaxCode('Code','PCGoodsInMaster',number);
close;
sql.Text := 'insert into PCGoodsInMaster ( CreateUserID,'
+' Date, Code, ClientID, EmployeeID, BillMode, '
+' ModeDC,ModeC, Brief, ClearDate, SundryFee, Apportion, '
+' Deliver, Memo, OriginID, OriginTable ) '
+' select CreateUserID,Date, '+ QuotedStr(code)+ ' ,'
+' ClientID, EmployeeID,BillMode ,'
+' ModeDC,ModeC, '+QuotedStr('采購開單自動提交') +' ,'
+' ClearDate, SundryFee, Apportion, '
+' Deliver, '+ QuotedStr('采購單號:')
+' +code, ID, '+QuotedStr('PCPurchaseMaster')
+' from PCPurchaseMaster '
+' where id=' +adsMaster.fieldbyname('ID').AsString
+' and RecordState<>'+QuotedStr('刪除')
+' and ID not in '
+' (select top 1 OriginID from PCGoodsInMaster where '
+' OriginTable='+ QuotedStr('PCPurchaseMaster')
+' and OriginID='+adsMaster.fieldbyname('ID').AsString+' )';
ExecSQL; //插入出庫主表記錄完畢
close;
sql.Text := 'select top 1 ID from PCGoodsInMaster where '
+' OriginTable='+ QuotedStr('PCPurchaseMaster')
+' and OriginID='+adsMaster.fieldbyname('ID').AsString;
open;
if adoTemp.IsEmpty then MasterID :=0
else MasterID :=adoTemp.FieldByName('ID').AsInteger;
sql.Text := 'insert into PCGoodsInDetail ( '
+' MasterID, GoodsID, GoodsSpec, '
+' Quantity, QuantityPcs, PackUnitID, '
+' GoalUnitID, GoalQuantity, Memo ) '
+' select '+ Inttostr(MasterID) + ' , a.GoodsID, a.GoodsSpec, '
+' a.Quantity, a.QuantityPcs, a.PackUnitID, '
+' a.GoalUnitID, a.GoalQuantity, a.Memo '
+' from PCPurchaseDetail a '
+' left outer join PCPurchaseMaster b on a.MasterID=b.ID'
+' where isnull(a.GoodsID,0)<>0 '
+' and isnull(a.GoalQuantity,0)<>0 '
+' and a.MasterID='+ adsMaster.fieldbyname('ID').AsString
+' and b.RecordState<>'+QuotedStr('刪除');
ExecSQL;//插入出庫子表記錄完畢
end;
end;
//判斷是否要插入銷售結算表
if ( adsMaster.FieldByName('BillMode').AsString ='現款采購' ) then
begin
// Exit;
adoTemp.Close;
adoTemp.SQL.Text :='select OriginID from FNClearPCMaster'
+' where OriginTable='+Quotedstr('PCPurchaseMaster')
+' and RecordState<>'+Quotedstr('刪除')+' and OriginID='
+ adsMaster.fieldbyname('ID').AsString ;
adoTemp.Open;
if adoTemp.IsEmpty then
begin
adoTemp.Close;
adoTemp.SQL.Text :=' select * from FNAccounts '
+' where AccountType like '+Quotedstr('%現金%')
+' and RecordState<>'+Quotedstr('刪除') ;
adoTemp.open;
AccountIDStr :=adoTemp.fieldbyname('ID').AsString;
if Trim(AccountIDStr)='' then AccountIDStr :='1';
IDStr :=adsMaster.fieldbyname('ID').AsString;
if Trim(IDStr)='' then IDStr :='0';
adoTemp.Close;
adoTemp.SQL.Text :=' Insert into FNClearPCMaster ('
+' CreateUserID,Date,Code,BillMode,ModeDC,ModeC,'
+' Brief, ClientID, EmployeeID,AccountsID, AmountD, '
+' AmountC,AmountRed,Memo, OriginID, OriginTable) '
+' select CreateUserID, Date, '
+Quotedstr(GetMaxCode('Code','FNClearPCMaster',number))+' , '
+Quotedstr('現購結算')+' BillMode, ModeDC, ModeC, '
+Quotedstr('現款采購')+' as Brief, '
+' ClientID, EmployeeID, '+ AccountIDStr+' as AccountID , '
+' 0.00 AmountD ,'
+' (isnull(b.Amount,0)+isnull(a.SundryFee,0)-isnull(CashDiscount,0) )'
+' as AmountC, '
+' CashDiscount, '
+Quotedstr('現款采購')+' as Memo, a.ID, '
+Quotedstr('PCPurchaseMaster')
+' from PCPurchaseMaster a '
+' left outer join '
+' ( select MasterID,Sum(Isnull(Amount,0)) as Amount '
+' from PCPurchaseDetail '
+' Group by MasterID ) b on B.MasterID=a.ID '
+' where a.ID='+IDStr ;
adoTemp.ExecSQL;
AccountIDStr := adsMaster.fieldbyname('ID').AsString;
if Trim(AccountIDStr)='' then AccountIDStr :='0';
adoTemp.Close;
adoTemp.SQL.Text :=' select ID from FNClearPCMaster '
+' where OriginID='+AccountIDStr+' and OriginTable='
+Quotedstr('PCPurchaseMaster') ;
adoTemp.Open; //選定新插入記錄(FNClearPCMaster表)的ID號
MasterIDStr :=adoTemp.fieldbyname('ID').AsString;
if Trim(MasterIDStr)='' then MasterIDStr :='0';
adoTemp.Close;
adoTemp.SQL.Text :=' Insert into FNClearPCDetail ('
+' MasterID,OriginID,Amount)'
+' select '+MasterIDStr +'as MasterID,'
+' a.ID as OriginID, '
+' (isnull(b.Amount,0)+isnull(a.SundryFee,0) ) as Amount '
+' from PCPurchaseMaster a '
+' left outer join '
+' ( select MasterID,Sum(Isnull(Amount,0)) as Amount '
+' from PCPurchaseDetail '
+' Group by MasterID ) b on B.MasterID=a.ID '
+' where a.ID='+IDStr ;
adoTemp.ExecSQL;
end;
end;
end;
procedure TPCEDPurchaseClothForm.adsDetailSizeAChange(Sender: TField);
begin
inherited;
adsDetail.Edit;
adsDetail.FieldByName('GoalQuantity').AsFloat :=adsDetail.fieldbyname('SizeA').AsFloat
+adsDetail.fieldbyname('SizeB').AsFloat+adsDetail.fieldbyname('SizeC').AsFloat
+adsDetail.fieldbyname('SizeD').AsFloat+adsDetail.fieldbyname('SizeE').AsFloat
// +adsDetail.fieldbyname('SizeF').AsFloat;
+adsDetail.fieldbyname('SizeF').AsFloat+adsDetail.fieldbyname('QuantityPcs').AsFloat ;
end;
procedure TPCEDPurchaseClothForm.SameQuantityActExecute(Sender: TObject);
begin
inherited;
if adsDetail.fieldbyname('SizeA').AsFloat=0 then
begin
adsDetail.FieldByName('SizeA').AsFloat :=adsDetail.fieldbyname('SizeB').AsFloat;
if adsDetail.fieldbyname('SizeA').AsFloat=0 then
adsDetail.FieldByName('SizeA').AsFloat :=adsDetail.fieldbyname('SizeC').AsFloat;
if adsDetail.fieldbyname('SizeA').AsFloat=0 then
adsDetail.FieldByName('SizeA').AsFloat :=adsDetail.fieldbyname('SizeD').AsFloat;
if adsDetail.fieldbyname('SizeA').AsFloat=0 then
adsDetail.FieldByName('SizeA').AsFloat :=adsDetail.fieldbyname('SizeE').AsFloat;
if adsDetail.fieldbyname('SizeA').AsFloat=0 then
adsDetail.FieldByName('SizeA').AsFloat :=adsDetail.fieldbyname('SizeF').AsFloat;
end;
adsDetail.Edit;
adsDetail.FieldByName('SizeB').AsFloat :=adsDetail.fieldbyname('SizeA').AsFloat;
adsDetail.FieldByName('SizeC').AsFloat :=adsDetail.fieldbyname('SizeA').AsFloat;
adsDetail.FieldByName('SizeD').AsFloat :=adsDetail.fieldbyname('SizeA').AsFloat;
adsDetail.FieldByName('SizeE').AsFloat :=adsDetail.fieldbyname('SizeA').AsFloat;
adsDetail.FieldByName('SizeF').AsFloat :=adsDetail.fieldbyname('SizeA').AsFloat;
// adsDetail.FieldByName('QuantityPcs').AsFloat :=adsDetail.fieldbyname('SizeA').AsFloat;
end;
procedure TPCEDPurchaseClothForm.adsDetailQuantityPcsChange(Sender: TField);
begin
EXIT;
inherited;
adsDetail.Edit;
adsDetail.FieldByName('SizeA').AsFloat :=adsDetail.fieldbyname('QuantityPcs').AsFloat/6;
adsDetail.FieldByName('SizeB').AsFloat :=adsDetail.fieldbyname('QuantityPcs').AsFloat/6;
adsDetail.FieldByName('SizeC').AsFloat :=adsDetail.fieldbyname('QuantityPcs').AsFloat/6;
adsDetail.FieldByName('SizeD').AsFloat :=adsDetail.fieldbyname('QuantityPcs').AsFloat/6;
adsDetail.FieldByName('SizeE').AsFloat :=adsDetail.fieldbyname('QuantityPcs').AsFloat/6;
adsDetail.FieldByName('SizeF').AsFloat :=adsDetail.fieldbyname('QuantityPcs').AsFloat/6;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -