Solved

printing from delphi part 2

Posted on 2004-04-09
1
193 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
1 Comment
 
LVL 11

Accepted Solution

by:
shaneholmes earned 300 total points
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

728 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now