01-03-2020, 03:39 PM
(28-02-2020, 10:45 PM)Omega-tron كتب : في حالة ان العميل دفع مبلغ اكبر من قيمة القسط يتم توزيعه علي الاقساط التالية وان كان فيه مبلع مدفوع من قسط يتم تكملنه وتسديد باقي الاقساط زي الصورة
[size=small]جرب هذه procedure حيث :
PriorPayment : المبلغ المدفوع من القسط سابقا
Payment : المبلغ المدفوع
Installment : قيمة القسط
Col : عمود الإضافة
Row : سطر الإضافة[/size]
كود :
procedure TForm2.DistributionInstallment(PriorPayment, Payment, Installment: Currency;
StringGrid: TStringGrid; Col, Row: Integer);
begin
if Payment <= 0 then
exit;
Payment:= Payment + PriorPayment;
repeat
if Payment > Installment then
StringGrid.Cells[Col, Row]:= CurrToStr(Installment)
else StringGrid.Cells[Col, Row]:= CurrToStr(Payment);
Payment:= Payment - Installment;
Row:= Row + 1;
until (Payment <= 0);
end;
procedure TForm2.InstallmentBtnClick(Sender: TObject);
begin
DistributionInstallment(80, 60, 150, StringGrid1, 3, 1);
end;

![[-]](https://delphi4arab.net/forum/D4A2020/collapse.png)