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
Solved

printing from delphi part 2

Posted on 2004-04-09
1
198 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
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

839 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