Solved

printing from delphi part 2

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
code issue 8 133
drawing animated level bar based on numbers 3 98
How to debug For loops? 3 50
how to make 2 step back? ..\..\ ExtractFilePath (paramstr(0)) 5 15
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

832 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