Solved

printing from delphi part1

Posted on 2004-04-09
1
172 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
ID: 10795133
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

920 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

12 Experts available now in Live!

Get 1:1 Help Now