Solved

printing from delphi part 2

Posted on 2004-04-09
1
200 Views
Last Modified: 2010-04-05
I have a POS form (modal) , which has a total transaction. I have a button which I click to accept payment (modal form also). I enter the payment amount, click the ok button and it shows the change. What i want is, to have it so, if The amount of change is < 0 then the receipt isn't satisfied and the form (modal POS form)  should not close.


ps. Shane if your out there i would really appreciate your help because he you know the pos

0
Comment
Question by:zgeorge_2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 11

Accepted Solution

by:
shaneholmes earned 300 total points
ID: 10795426
K, Quick & Dirty, here it is:



procedure TfrmMainPOS.UpdateTotals;
var
 Qty: Integer;
 Cost: Real;
 GSTTax: Real;
 PSTTax: Real;
 TotalTax: Real;
 GrandTotal: Real;
 Tender: Real;
 Balance: Real;
begin
 Qty:= 0;
 Cost:= 0.00;
 GetTotals(Qty, Cost);
 sttTotalQty.Caption:= IntToStr(QTY);
 sttTotalCost.Caption:= FormatFloat('0.00',Cost);
 GSTTax:= Cost * GST;
 PSTTax:= Cost * PST;
 TotalTax:= GSTTax + PSTTax;
 sttTotalTax.Caption:= FormatFloat('0.00', TotalTax);
 sttGrandTotal.Caption:= FormatFloat('0.00', Cost + TotalTax);
 GrandTotal:= StrToFloat(sttGrandTotal.Caption);
 Tender:= StrToFloat(sttTendered.Caption);
 sttBalance.Caption:= sttGrandTotal.Caption;
 Balance:= StrToFloat(sttBalance.Caption);
 sttBalance.Caption:= FormatFloat('0.00', Balance - Tender);
end;


procedure TfrmMainPOS.actPaymentExecute(Sender: TObject);
var
 I: Integer;
 Tender, Balance, Change: Real;
begin
 if frmAmount.ShowModal = mrOK then
 begin
  sttTendered.Caption:= frmAmount.edtAmount.Text;
  sttChange.Caption:= FormatFloat('0.00',
                      strToFloat(sttTendered.Caption)-
                      strToFloat(sttGrandTotal.Caption));

  Change:= StrToFloat(sttChange.Caption);
  if Change < 0.00 then sttChange.Caption:= '0.00';

  Tender:= StrToFloat(sttTendered.Caption);
  Balance:= StrToFloat(sttBalance.Caption);

  if Tender <= Balance then
  begin
   Balance:= Balance - Tender;
   sttBalance.Caption:= FormatFloat('0.00',Balance);
  end;

 frmData.tblTransactions.Edit;
 frmData.tblTransactions.Insert;
 frmData.tblTransactions.FieldByName('Date').asString:= FormatDateTime('mm/dd/yy',Now);
 frmData.tblTransactions.FieldByName('Time').asString:= FormatDateTime('hh:mm:ss am/pm',Now);
 frmData.tblTransactions.FieldByName('Quantity').asString:= sttTotalQty.Caption;
 frmData.tblTransactions.FieldByName('Cost').asString:= sttTotalCost.Caption;
 frmData.tblTransactions.FieldByName('Tax').asString:= sttTotalTax.Caption;
 frmData.tblTransactions.FieldByName('Total').asString:= sttGrandTotal.Caption;
 frmData.tblTransactions.FieldByName('Payment').asString:= frmAmount.cbxPayment.Text;
 frmData.tblTransactions.Post;

 for I:= 0 to lvwReceipt.Items.Count - 1 do
 begin
  frmData.tblTransItems.Edit;
  frmData.tblTransItems.Insert;
  frmData.tblTransItems.FieldByName('TransId').asString:= frmData.tblTransactions.FieldByName('Id').asString;
  frmData.tblTransItems.FieldByName('Date').asString:= FormatDateTime('mm/dd/yy',Now);
  frmData.tblTransItems.FieldByName('Time').asString:= FormatDateTime('hh:mm:ss am/pm',Now);
  frmData.tblTransItems.FieldByName('Item').asString:= lvwReceipt.Items[I].Caption;
  frmData.tblTransItems.FieldByName('Category').asString:= frmData.GetCategory(lvwReceipt.Items[I].Caption);
  frmData.tblTransItems.FieldByName('Qty').asString:= lvwReceipt.Items[I].SubItems[0];
  frmData.tblTransItems.FieldByName('Price').asString:= lvwReceipt.Items[I].SubItems[1];
  frmData.tblTransItems.FieldByName('Total').asString:= lvwReceipt.Items[I].SubItems[2];
  frmData.tblTransItems.Post;
 end;
 end;
end;


procedure TfrmMainPOS.actReturnExecute(Sender: TObject);
begin
 if StrToFloat(sttBalance.Caption) = 0.00 then
 begin
  lvwReceipt.Items.BeginUpdate;
  lvwReceipt.Items.Clear;
  lvwReceipt.Items.EndUpdate;
  UpdateTotals;
  sttTendered.Caption:= '0.00';
  sttChange.Caption:= '0.00';
  ModalResult:= mrOK;
  Close;
 end
 else
 ShowMessage('Balance = ' + sttBalance.Caption);
end;



0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question