Solved

printing from delphi part1

Posted on 2004-04-09
1
171 Views
Last Modified: 2010-04-05
I have a POS application. I am trying to format my text before I print it.
I need to add Store Name, address, & phone number,
Date & Time, - as well as some formating of the receipt items. I also need to add two types of taxes (GST, PST)



ps. If Shane Holmes is out there, i'd appreciate his help, since he knows all about the POS
0
Comment
Question by:zgeorge_2
1 Comment
 
LVL 11

Accepted Solution

by:
shaneholmes earned 500 total points
Comment Utility
Hi George, Its added and I have emailed you the code.

Modified the following

procedure TfrmMainPOS.actPrintExecute(Sender: TObject);
var
 I: Integer;
begin
 with frmPrint.memPrint.Lines do
  begin
   Add(StoreName);
   Add(StoreAddress);
   Add(StoreCity + ', ' + StoreProvince + '  ' + StorePostal);
   Add(StorePhone);
   Add('');
   Add(DateTimeToSTr(Now));
   Add('');
   for I:= 0 to lvwReceipt.Items.COunt - 1 do
    Add( lvwReceipt.Items[I].SubItems[0] + '  ' +
         lvwReceipt.Items[I].Caption + '  ' +
         lvwReceipt.Items[I].SubItems[1] + '  ' +
         lvwReceipt.Items[I].SubItems[2]);
   Add('');
   Add('Total Items = ' + sttTotalQty.Caption);
   Add('Total Cost = ' + sttTotalCost.Caption);
   Add('Total Tax = ' + sttTotalTax.Caption);
   Add('Grand Total = ' + sttGrandTotal.Caption);
  end;
 if frmPrint.ShowModal = mrOK then
 begin
  if DefaultPrinter <> '' then
   PrintMemo(frmPrint.memPrint, False, False);
 end;
end;

procedure WriteRegistry;
var
 Reg: TRegistry;
begin
  Reg := TRegistry.Create;
  try
    Reg.RootKey := HKEY_CURRENT_USER;
    if Reg.OpenKey('\Software\POS\', True) then
    begin
     Reg.WriteFloat('GST', GST);
     Reg.WriteFloat('PST', PST);
     Reg.WriteString('Store Name', StoreName);
     Reg.WriteString('Store Address', StoreAddress);
     Reg.WriteString('Store City', StoreCity);
     Reg.WriteString('Store State', StoreProvince);
     Reg.WriteString('Store Postal', StorePostal);
     Reg.WriteString('Store Phone', StorePhone);
     Reg.CloseKey;
    end;
  finally
    Reg.Free;
  end;
end;

procedure ReadRegistry;
var
 Reg: TRegistry;
begin
  Reg := TRegistry.Create;
  try
    Reg.RootKey := HKEY_CURRENT_USER;
    if Reg.OpenKey('\Software\POS\', True) then
    begin
    if Reg.ValueExists('GST') then
     GST:= Reg.ReadFloat('GST')
    else
     GST:= 0.08;
    if Reg.ValueExists('PST') then
     PST:= Reg.ReadFloat('PST')
    else
     PST:= 0.07;
    if Reg.ValueExists('Store Name') then
     StoreName:= Reg.ReadString('Store Name')
    else
     StoreName:= 'Acme Store';
    if Reg.ValueExists('Store Address') then
     StoreAddress:= Reg.ReadString('Store Address')
    else
     StoreAddress:= '111 Anywhere';
    if Reg.ValueExists('Store City') then
     StoreCity:= Reg.ReadString('Store City')
    else
     StoreCity:= 'Toronto';
    if Reg.ValueExists('Store Provice') then
     StoreProvince:= Reg.ReadString('Store Provice')
    else
     StoreProvince:= 'ONT';
    if Reg.ValueExists('Store Postal') then
     StorePostal:= Reg.ReadString('Store Postal')
    else
     StorePostal:= 'M4X 1M9';
    if Reg.ValueExists('Store Phone') then
    StorePhone:= Reg.ReadString('Store Phone')
    else
     StorePhone:= '';
     Reg.CloseKey;
    end;
  finally
    Reg.Free;
  end;
end;

Shane
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

772 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

15 Experts available now in Live!

Get 1:1 Help Now