Solved

printing from delphi part 2

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
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…

756 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