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.
(
Using seek and read from customerfile.) after that the user will ask which item number of the stockfile the customer pick(
again using seek and read from stockfile) 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('œ',stock.sellprice:0:0);
gotoxy(47,line);
writeln(stock.status);
gotoxy(57,line);
write('x');
read(howmany);
cache.total:=cache.total+stock.sellprice*howmany;
gotoxy(72,line);
writeln('œ',cache.total:0:0);
end;
end;
end;
end;
end;
end;
writeln('Please input the total amount.');
readln(payment);
cache.total:=payment-cache.total;
writeln('Change: ',cache.total:0:2);
writeln('Purchase successful. Tnx');
cache.status:='A';
seek(cachefile,cache.number-1);
write(cachefile,cache);
repeat until keypressed;
end;
---------------------------------------------------------------------
this is the procedure I made so far for the receipt.. please need help on how to copy a certain files from 2 record to a new record file so I can view the customers recent transaction and stuff like this.. need it few days from now so i can study and understand it further more... T,T HOPE anyone could help me with this