Need some Help! on Record please..

Hello! I need some help on my program... I am making a program which is about a certain shop, with 3 records which is : Stock records, Employee records, and Customer records. I have already made procedures on each of this records which is, add, view, list, delete, search, sort, modify, backup, and restore. Each record in 3 menu's "Stocks, Employee, and Customer.."

My problem is that... my teacher ask me to make my program do some real programing like computing and stuff or external sort i think it was he said.. But I choose to add another program which is called receipt

where I add new procedure called receipt. where the user will ask for the customer's ID, then its name will display on the screen.
([u]Using seek and read from customerfile[/u].) after that the user will ask which item number of the stockfile the customer pick([u]again using seek and read from stockfile[/u]) then the info of the stock item will be displayed on the screen (from stock records) along with the name of the customer(from the customer record). It will then ask how many? then multiply the total and receive the payment and calculate the change... <-- which is a new var in this procedure.

Now what I want is after making another menu for this procedure, called receipt. I want to copy all the information above to this new record/a 4th record where it will store the info on which customer, what items he bought and how many he bought, total and change..
so that in the sub menu I could use the procedure which displays the customers recent transaction. But I dont know how to copy a certain file on the 2 record files which is stock and customer in order to save it to the new record called receipt.




---------------------------------------------------------------------
procedure buy;

var which_customer_num: integer;
which_stock_num: integer;
howmany: integer;
proceed: char;
payment: real;
change:real;
fs: integer;
total:integer;
line:integer;


begin
line:=14;
fs:=filesize(cachefile);
cache.number:=fs+1;
clrscr;
cache.total:=cache.total;
banner;
title('Cache Menu');
gotoxy(1,9);
write('Customer number #: ');
readln(which_customer_num);

seek(customerfile,0);

while not eof(customerfile) do

begin
read(customerfile,customer);
if (customer.status='A') AND (which_customer_num=customer.customnumber) then
begin
writeln('CUSTOMER NAME: ',customer.forename,' ',customer.surname);
begin
which_stock_num:=-1;
while which_stock_num <>0 do
begin
write('Item number : ');
readln(which_stock_num);
gotoxy(1,13);write('ITEM NO.');
gotoxy(11,13);write('GUITAR BRAND');
gotoxy(25,13);write('STOCK TYPE ');
gotoxy(38,13);write('PRICE');
gotoxy(47,13);write('STATUS ');
gotoxy(57,13);write('NO.OF.ITEMS ');
gotoxy(72,13);write('TOTAL ');
seek(stockfile,0);
while not eof(stockfile) do
begin
read(stockfile,stock);
if (stock.status='I') AND (which_stock_num=stock.stocknumber) then
begin
gotoxy(1,line);
writeln(stock.stocknumber);
gotoxy(11,line);
writeln(stock.description);
gotoxy(25,line);
writeln(stock.stocktype);
gotoxy(38,line);
writeln('

Comments

  • I would create a subrecord for each costumer for the purchases and just save it back to the costumer file ( seek backward 1 record length (bytes)). Then each time the costumer data is read the purchase record is retrieved instantly...
    Here you can find a well written database program: http://www.programmersheaven.com/mb/pasprog/384937/384937/dos-pascal-dat-service-request/?S=B20000#384937
  • I'm sorry about the late reply Atex... I've tried understanding the link you gave me but nothing goes through my mind... Im still new to pascal programming and still learning.
    I was some what posting all this help to other pascal programing site forums assking for help but still got nothing.
    I didnt notice I could attach files here... would you mind checking my program, Im sorta still in the basic its about making some sort of recciept from a guitar shop... and still a lil confused on using records... or maybe could you help me fix the problem please... I just dontk now how to copy a file from the customerrecord e.g.(customer name), and another files from stockrecord e.g.(item no., brand, sell price, status, no. of items) to another new reccord of some sort.
    So that I could use the 2nd procedure (Display recent Transaction)
    --->> where it will display (customers name), (information of the stock the customer bought, total, and change.)
    So far this is what I got...

    Hope you could fix the problem.. T,T

  • Time permitting will go through your code and see what can I come up with...

  • Yes please, I'd really appreciate it. =>
  • You could try:[code][color=Blue]type transaction_record=record
    field_a:customerrec;
    field_b:stockrec;
    end;

    var transaction_record_file:file of transaction_record;[/color][/code]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories