Deleting / Discontinuation of stock
Stock items are never actually deleted from the file, they are just discontinued. This is for warrantee purposes as a customer may buy a product that may then become discontinued and if we had no record of this item ever being in stock problems would occur when the customer requests a refund.
Data requirements
- Stock name The stock items name
- Stock number The unique number given to the item
Problems
Once a stock item has become discontinued this is marked with a D in the top left corner of the stock record. A member of staff may overlook this on occasion and they are then left wondering why there is no stock there.
1.4 – Time Plan
1.5 – Interview
I carried out an interview with Mr. Williams to see what changes he thought his store needed.
Interview Transcript:
Myself: Hi, I would like to thank you first for giving up your time to help me with this interview.
Mr. Williams: Not at all.
Myself: Ok, lets get started. At the moment you are using a manual system, could tell me the main problems that you have with this system.
Mr. Williams: Well, what isn’t a problem would be an easier question to answer. I think the main problem we get is all the handwritten documents. It is not the actual writing of these documents such as the sorting, filing and invoicing. This method of arranging is slow and costly as my staffs are paid on an hourly basis. Also the quality, because it is handwritten, is poor. Oh and there is also the fact that many documents are lost which is an incredible waste of time because then all the files have to be checked.
Myself: Have you tried any other methods? And if so please specify.
Mr. Williams: No, I have tried no other method, but I really think I need to.
Myself: How long have you thought about changing this system?
Mr. Williams: I have been thinking about changing the system for a while now, the reason I haven’t made much progress is the lack of time. We are rushed off our feet.
Myself: What exactly do you want out of this new system?
Mr. Williams: My main idea was to get a new filing system. The one we have now is dreadful and it takes too much time to find a document. And when a comes in at the end of a long day with her children screaming that they want to go home and you can’t find the document she needs it is chaotic. Also when the stock deliverer comes to deliver stock, trying to find our stock order form in all the papers is a nightmare.
Myself: What benefits do you think a computerised system would provide for you?
Mr. Williams: Well, firstly it would be much quicker. We could easily access all our file, weather it be stock or member. It would stop us muddling up our filing system and spending a lot of time trying to sort it out for it to be disarranged the very next day. We get so much work in every day to file and we just lose track so if we didn’t have to worry about the filing because a computer did it for us, then great.
Myself: Do you have any ideas about security and access?
Mr. Williams: Well, yes. Even though there is only two of us in the shop some times the store is left so we can go to the stock room, at this point the customer would be able to access the files if they were not protected.
Myself: Would you want the whole program protected, or would you allow the customers to browse through certain parts?
Mr. Williams: Well, I see no trouble with the customer being able to view stock, but I don’t think they should be able to view each other’s details or change details on the files.
Myself: That’s fair enough. Is there anything specific that you think you would need?
Mr. Williams: Yes, I think being able to change my password regularly would really help, as I am one to chat. Oh and I wonder if it is possible to be able to view all stock or view only current stock because all stock must be stored on our data base even if it is discontinued. This is due to our warrantees, no stock is ever deleted from our stock records so that if a customer comes in with a product wanting a refund then we can know weather we stocked that product at any time.
Myself: Yes that is possible. Anything else?
Mr. Williams: Well, I’m not sure. I don’t really use computers much; you’re the expert I think I will leave it up to you.
Myself: Ok I think that is all I need.
I’m sorry I’ve kept you so long, thank you for your.
Mr. Williams: Not at all, good day to you.
Interview summary
Mr. Williams was unsure about how he wanted to improve his store. However he was quite adamant that he needed a new, easier and faster filing system. He would also like the program free for his customers to view but for there to be a password on the member’s section and any modifying sections.
He would also like the ability to change his password regularly.
Questionnaire
I designed a questionnaire for Mr. Edwards and two customers to fill out on what they thought of the store.
Please write … V for Very good
G for good
S for Satisfactory
P for poor
Please complete all of the following questions…
[1] How efficient is the current system?
[2] What do you think of the products?
[3] How well do the staffs treat customers?
[4] How well is the store run?
[5] How is service time?
Please fill in the remaining questions with a Black pen…
[6] How do you think the current system may be improved?
[7] Please give details about the current system and staff members
Please write … V for Very good
G for good
S for Satisfactory
P for poor
Please complete all of the following questions…
[1] How efficient is the current system?
[2] What do you think of the products?
[3] How well do the staffs treat customers?
[4] How well is the store run?
[5] How is service time?
Please fill in the remaining questions with a Black pen…
[6] How do you think the current system may be improved?
[7] Please give details about the current system and staff members
Please write … V for Very good
G for good
S for Satisfactory
P for poor
Please complete all of the following questions…
[1] How efficient is the current system?
[2] What do you think of the products?
[3] How well do the staffs treat customers?
[4] How well is the store run?
[5] How is service time?
Please fill in the remaining questions with a Black pen…
[6] How do you think the current system may be improved?
[7] Please give details about the current system and staff members
Please write … V for Very good
G for good
S for Satisfactory
P for poor
Please complete all of the following questions…
[1] How efficient is the current system?
[2] What do you think of the products?
[3] How well do the staffs treat customers?
[4] How well is the store run?
[5] How is service time?
Please fill in the remaining questions with a Black pen…
[6] How do you think the current system may be improved?
[7] Please give details about the current system and staff members
1.4 – System Constraints
For the computerised system I will need many items of software and hardware. Here is a brief list of some hardware and software examples I will need.
- Pc with an 800mhz processor and a 16mb graphics card. At least 1gb hard disk.
Reason: This will be used to run the system and save information to the hard disk for future reference and/or amending.
- 15” Colour CRT Monitor
Reason: To be display the chosen program.
- Printer, possibly colour with 600dpi resolution of better
Reason: To print out forms or other things needed on the system.
- Operation system – MSDOS or Windows
Reason: This software is needed to run the program
- Drivers. For: Printer, monitor, graphics card, MSDOS, Sound card.
Reason: Drivers are needed to run the system.
Limitations
For this new system I have decided to use the bare minimum. This is because when I spoke to Mr. Williams he said…
“Well we are not made of money; a cheaper system will be much approved.”
Also this system will need to be set up and running in one day.
“We only close on Sundays and hopefully it will be enough time to get the system running”
This may cause problems as there are many things that may cause problems.
2 – Design
2.1 – Alternate Methods
It has been decided that the new system is to be computerised. However there are many different types of programs that can be used for this new system.
Off Shelf Package –
- Already Developed – Saves time as you just have to buy it
- Documented – Comes with User Documentation
- Simple – It is designed for all users so is simple to use
- Debugged – Will have been debugged extensively
- Not specific – Designed for the majority, not specific to what we need
- Updating – Needs updates regularly
Rapid Application Design
- Quick – Quickly-produced prototypes to enable to customer to see the proposed system
- Low Cost – Is fairly cheap compared to the other options
- Quick – Things are not thought out thoroughly, therefore may get bugs in the system
- Documentation – All Documentation has to be made
- Updating – Will need Bug fixes
Pascal
- Familiar – I am used to working with Pascal
- Specific – Can be coded to be unique
- Amended – It can easily be changed to suit needs
- Procedures – It utilises procedures to perform a variety of tasks
- Documentation – All Documentation needs to be hand written
- Time – May take a long time to write code
- Updating – No updates will be available
2.2 - Justification
I have decided to use Pascal to create the program needed for the stores new system. This is generally because I am used to coding with it and it allows me to make a specified program at a low cost. It will mean having to write all my own user documentation and may take time fir me to write the code for the program. A useful feature about Pascal is that it can utilise procedures to perform a variety of tasks. The code I use can be easily amended if mistakes are made and it will be of low costs.
2.3 – Identification of procedures
For the new system I will have to introduce a number new of new or amended procedures.
Processes
Adding a Stock it em
When a new stock item is purchased and arrives at the store, immediately a record of the stock is made.
Data requirements
- Number Unique stock number given to that item only
- Title Name or title of the stock item
- Description Description of what the stock item is
- Price Price of the stock
- Status Status of the stock: Available Unavailable Discontinued
Problems Solved
Once the stock item has been added to the file it can not be deleted, just modified. And because it is saved to file there are no worries about the presentation of the writing.
View Stock Details
The Id of the product may be entered into the program – the program will search the file and find the stock details with the corresponding ID number.
Data Requirements
- Stock Number A unique stock number given by a member of staff
Problems Solved
This displays just the item searched for, it will display all the properties of the stock item and tell the staff member or customer if the item is Available, Unavailable or Discontinued.
View All Stock
This will display all the stock on the stock file weather it is available, unavailable or discontinued.
Data Requirements
Problems Solved
This allows you to view all stock and stock details on the computer screen rather than having to dig out old files and pull out pages and pages.
View Current Stock
This will display the current stock on the stock file. Only available stock will be shown.
Data Requirements
Problems Solved
This allows you to view current stock and stock details on the computer screen rather than having to dig out old files and search for only stock that is currently available.
Amending stock status
This allows you to modify the stock status to show weather the stock is Available, Unavailable or Discontinued.
Data requirements
- Password A password must be entered to get access to this section
- Stock Number The unique stock number given to this item
Problems solved
Again this means you do not have to go ranting and raving through files to find weather the stock is available or not as it is displayed on the screen. Once access has been gained to the modify stock section the stock number is required, after this has been entered you are prompted to change the status to A, D or U, this will be saved to the stock file for further reference.
2.4 – File Structures
For the new system, there will be 2 files at CP3. There will be a Stock file holding all the stock records, and a password file allowing you to change the password.
I will use the record structure stock=record, with the fields stocknum, title, description, status, price.
Staffnum is the only key field as it gives each item of stock once added a special number that is unique to it. If there is a stock number that has been entered, and the user enters the same number the one currently there is simply overridden. To prevent this you would have to use Validation, and I will not be using this until the second year of the project.
To be able to store records firstly you need a file on your local hard disk, and second a command in the program that assigns a certain variable to the record structure, and the file on the local disk.
To do this I will do the following:
In the global variables I used a variable called – stock_file : file of stock;
This will make it possible to then link the assign line to the record structure. When I wanted to write or read stock I simply entered the line
assign(stock_file,’C:stock.dat’);
and
reset(stock_file); to open the file.
Files stored in the stock file are determined by the stocknum given to them. As this is unique there can be no 2 records in the same place. This then gives us the option of direct access (instead of looking for the file, going straight to it using the seek command i.e. instead of searching all of the map for a hotel you use a grid reference which directs you to the position of the hotel. This grid reference is the same as the seek command). To display all of the records within the file you can simply use the
While not eof command in a loop to display each stock item and its linked variable i.e. description, title, price.
When the user wants to modify, view a stock item he/she simply enters the corresponding stocknum into the program and the program automatically seeks the position in the file and displays the stock record to the screen. This process is known as direct access, explained above in brackets.
To search by the title of a item of stock, which I will included in the program, the program simply seeks to the start of the file stock.dat, then reads each item into a variable while not eof. The system then proceeds to checking if the title that has been entered is the same as one in the file in sequential order. Once it has found that file it writes it to the screen.
File Details:
Used by ;
Fields.
2.4 – Testing Strategy
To Test the system I will be using several methods of testing such as Beta and top-down.
Beta testing consists of giving the program to others to test and go through before the real product is given out. This system helps spot bugs early and can give designers feedback about what else he/she might include.
Top-Down testing consists of the skeleton of the complete system being tested, with individual modules being replaced by ‘stubs’, which may for example display a message to say that a certain procedure has been executed. As individual modules are completed they are included in subsequent tests.
I will also use logical testing to make sure that for example the correct loop is executed at the correct time, to make sure the system works properly. This will be an extra test, which will identify small errors, which the other two tests may not of, picked up on.
Functional testing will also be used; this involves creating a set of test data that covers all the inputs and outputs of the program functions.
3 – Implementation
3.1 – Module designs
Module Details:
Procedures/Functions used :
Local Variable List :
Pseudo code :
Module Description Form
Module Details:
Called from :
Procedures/Functions used :
Local Variable List :
Pseudo code :
Module Description Form
Module Details:
Called from :
Procedures/Functions used :
Local Variable List :
Pseudo code :
3.1(b) – Pseudo Code
program system
stock structure
stocknum
title
rating
description
status
prices
var
all global variables, to link to structure and sorts
procedure banner
background=black
clear screen
gotoxy(1,1)
write('Title');
gotoxy(1,25)
write('Copyright .....');
end;
procedure title(headin:string);
background=blue
text-white
date;
write(' ',heading,' ')
end;
procedure add_stock
write(stock number)
read (stockrecord.stocknum)
repeat for other variables
seek(stock_file,stockrecord.stocknum)
write)stock_file,stockrecord)
end;
procedure view_stock
ask user for a stock number
find the numbe rin the file
display its details to the screen
end;
procedure modify stock
request stocknumber to change
find stocknumber entered
ask for status change
end;
procedure viewall_stock
heasdings
read stock-file
display all items
by displaying one then inc the line< repeat loop
only allow 10 items to be displayed at once, let user press a key to move to the next 10
procedure change_password
password = record
passwd : string
end;
var
all needed
begin
assign(password_file,'password.dat');
reset(password_file);
if filesize(password_filwe)=0 then
begin
writeln('No current password set');
write(eneter a password);
read
write to file
else
read (password_file,passwordrecord);
write(current pass);
readln(inpas);
if inpass = passwordrecord.passwd then
write (changing pass: new pass)
readln
else
write(wrong pass);
end;
procedure password;
var
needed
request password
check entered password with passwordrecord.passwd
if correct proceed
if not then repeat above
end;
procedure members
write(not available);
end;
procedure viewcurrent_stock
read (stock_file);
filter out all items without status = 'A'
write all items with statyus = 'a' to screen
limit to 10 items
end;
procedure stock_menu
menu
display options that link to stock
i.e
write(1...add new stock)
write(2...view stock);
write (3...view all stock)
write(4...sort stock)
write(5..Exit)
case option of
'1' : add_stock
'2' : view-stock;
'3' : viewall_stock;
'4' : sort_stock
until option = 5
end;
procedure admin_menu
display admin options like sotck_menu
end;
procedure menu
a simple loading screen
display options that link to other menus like stock-menu or members or admin-menu
end;
begin
menu;
end.
3.2 - Annotated Program
Program project;
{----!This is the stock system for a Computer Store----}
{----!It allows you to search, add, modify, delete or sort stock----}
Uses crt, DOS;
Type
stock = Record
stocknum : Integer;
title : String [20];
Price : Integer;
description : String [15];
status : Char;
End;
Var
stock_file : File Of stock;
stockrecord : stock;
anykey : Char;
option : Char;
count: Integer;
finished : BOOLEAN;
Procedure banner;
{----!This section creates the header and footer of the program----}
Begin
TextBackground (Black);
ClrScr;
GotoXY (24, 1); TextColor (White); Write ('Whitesoul Design Systems Limited');
ClrEol;
GotoXY (28, 2); Write ('Computer Stock Database'); ClrEol;
GotoXY (24, 3); Write ('********************************'); ClrEol;
GotoXY (25, 24); Write ('*******************************'); ClrEol;
GotoXY (25, 25); Write ('Copyright Craig Pickrell 2003 ¸'); ClrEol;
End; {procedure}
Procedure add_stock;
{----!The adding stock section. This section allows----}
{----!you to add stock to the stock file----}
Begin
banner;
GotoXY (32, 7); Write ('Add A Stock Item');
GotoXY (30, 10); Write ('Please complete the following fields:');
GotoXY (30, 12); Write ('Stock number: ');
TextColor (Red);
ReadLn (stockrecord. stocknum);
GotoXY (30, 14); TextColor (White); Write ('Title: ');
TextColor (Red);
ReadLn (stockrecord. title);
GotoXY (30, 16); TextColor (White); Write ('Description: ');
TextColor (Red);
ReadLn (stockrecord. description);
GotoXY (30, 18); TextColor (White); Write ('Price: ');
TextColor (Red);
ReadLn (stockrecord. price);
GotoXY (30, 20);
stockrecord. status := 'A';
Seek (stock_file, stockrecord. stocknum);
Write (stock_file, stockrecord);
End; {procedure}
Procedure view_stock;
{----!Viewing the stock. This allows you to view a stock----}
{----!item on the stock file----}
Var
target : Integer;
numrec: Integer;
CH: Char;
Begin
banner;
GotoXY (31, 7); Write('View Stock Details');
GotoXY (30, 10); Write ('Enter the Stock Number: '); TextColor (Red);
ReadLn (target);
IF (target> 0) AND (target<filesize(stock_file)) THEN
BEGIN
Seek (stock_file, target);
Read (stock_file, stockrecord);
GotoXY (30, 12); TextColor (White);
Write ('Stock Number: ', stockrecord. stocknum);
GotoXY (30, 14); Write ('Title: ', stockrecord. title);
GotoXY (30, 16); Write ('Description: ', stockrecord. description);
GotoXY (30, 18); Write ('Price: ', stockrecord. price);
If stockrecord. status <> 'A' Then
Begin
GotoXY (30, 11); TextColor (Red + Blink); Write ('This Stock ');
If stockrecord. status = 'U' Then Write ('is UNAVAILABLE');
If stockrecord. status = 'D' Then Write ('was DISCONTINUED');
TextColor (Yellow);
End; {If statement}
End {if stock record exists}
ELSE
BEGIN
GotoXY(18,5);
Writeln('**This Stock Number Does Not Currently Exist**');
END; {stock does not exist}
GotoXY (30, 22); TextColor (Green); Write ('Press any key to continue');
anykey := ReadKey;
end; {procedure}
Procedure modify_stock_status;
{----!This section is restricted by a password, but once----}
{----!unlocked it has the ability to change the data stored on the file----}
Var
whichmod : Integer;
Begin
banner;
GotoXY (31, 7); Write('Modify Stock Status');
GotoXY (20, 10); Write ('Which Stock (Type Stock Number): ');
TextColor (Red);
ReadLn (whichmod);
Seek (stock_file, whichmod);
Read (stock_file, stockrecord);
TextColor (White); Gotoxy (12, 14);
WriteLn ('Change status to Unavailable, Discontinued, Available: ');
GotoXY (28, 15); Write ('Please enter U D or A: ');
TextColor (Red);
ReadLn (stockrecord. status);
Seek (stock_file, whichmod);
Write (stock_file, stockrecord);
End; {procedure}
Procedure viewall_stock;
{----!This section lets you view the stock that there is currently in stock----}
Var
Line : Integer;
numrec : Integer;
CH: Char;
Begin banner;
GotoXY (14,7); Write('View All Stock');
numrec := 0;
Line := 11;
Seek (stock_file, 1);
TextColor (Red);
GotoXY (1, 9);
Write ('ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿');
TextColor (Green);
GotoXY (10, 9); WriteLn ('Press PageDown to view remaining stock');
TextColor (red);
GotoXY (1, 10); Write ('³StockNumber');
GotoXY (16, 10); Write ('Title');
GotoXY (36, 10); Write ('Description');
GotoXY (51, 10); Write ('Price');
GotoXY (59, 10); Write ('Status³');
While Not EoF (stock_file) Do
Begin
Read (stock_file, stockrecord);
If (stockrecord. status = 'A') Or (stockrecord. status = 'D') Or (stockrecord. status = 'U') Then
Begin
TextColor (White);
Begin
TextColor (Red);
GotoXY (1, Line); Write ('³');
End;
TextColor (White);
GotoXY (4, Line); Write (stockrecord. stocknum);
GotoXY (16, Line); Write (stockrecord. title);
GotoXY (36, Line); Write (stockrecord. description);
GotoXY (51, Line); Write (stockrecord. price);
Begin
TextColor (Red);
GotoXY (65, Line); Write ('³');
End;
TextColor (White);
GotoXY (59, Line); Write (stockrecord. status);
Line := Line + 1;
numrec := numrec + 1;
If numrec = 10 Then
Repeat
Begin
TextColor (Red);
GotoXY (1, Line); Write ('ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ');
End;
CH := ReadKey;
If CH = #0 Then
Begin
CH := ReadKey;
If Ord (CH) = 81 Then
Begin
For Line := 11 To 21 Do
Begin
GotoXY (1, Line);
ClrEol
End;
Line := 11
End;
numrec := 0;
End;
Until Line = 11;
End;
End;
Begin
TextColor (Red);
GotoXY (1, Line); Write ('ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ');
End;
WriteLn;
WriteLn;
TextColor (Green);
GotoXY (10, 9);
WriteLn ('Press any key to return to Stock Menu');
anykey := ReadKey;
End;
Procedure change_password;
Type
password = Record
passwd : String [10];
End;
Var
password_file : File Of password;
passwordrecord : password;
anykey : Char;
inpassword: String [10];
Begin
ClrScr;
Assign (password_file, 'a:\password.txt');
Reset (password_file);
If FileSize (password_file) = 0 Then
Begin
GotoXY (28, 6); WriteLn ('No current password set');
GotoXY(20, 8); Write ('Changing password : Enter new password: ');
GotoXY (50, 8); ReadLn (passwordrecord. passwd);
Reset (password_file);
Write (password_file, passwordrecord);
End {if statement}
Else
Begin
Read (password_file, passwordrecord);
GotoXY(27, 8); Write ('Type in current password: ');
GotoXY (53, 8); ReadLn (inpassword);
If inpassword = passwordrecord. passwd Then
Begin
Write ('Changing password : Enter new password: ');
ReadLn (passwordrecord. passwd);
Reset (password_file);
Write (password_file, passwordrecord);
End
Else
GotoXY (22,15); WriteLn ('You have entered the wrong password');
End {else}
End; {procedure}
Procedure password;
{----!This section is the password section which stop people----}
{----!accessing the modifying section without the correct password----}
Type
password = Record
passwd : String [10];
End;
Var
password_file : File Of password;
passwordrecord : password;
anykey : Char;
inpassword: String [10];
thekey: Char;
userpass: String [8];
password2 : String [10];
Begin
Assign (password_file, 'a:\password.txt');
Reset (password_file);
Read (password_file, passwordrecord);
Repeat
userpass := '';
banner;
GotoXY (18, 10); TextColor (White);
Write ('Please enter the password for this section: ');
Repeat
thekey := ReadKey;
Write ('*');
If Ord (thekey) <> 13 Then userpass := userpass + thekey;
Until Ord (thekey) = 13;
Until userpass = passwordrecord. passwd;
modify_stock_status;
End; {procedure}
Procedure members;
Begin
ClrScr;
GotoXY (30, 10);
Write ('Comming soon in CP6!');
GotoXY (16, 11);
Write ('Currently only the stock section is available!');
ReadLn;
End; {procedure}
Procedure viewcurrent_stock;
{----!This section lets you view the stock that there is currently in stock----}
Var
Line : Integer;
numrec : Integer;
CH: Char;
Begin
banner;
GotoXY (31,7); Write('View Current Stock');
numrec := 0;
Line := 11;
Seek (stock_file, 1);
TextColor (Red);
GotoXY (1, 9); Write ('ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿');
TextColor (Green);
GotoXY (10, 9); WriteLn ('Press PageDown to view remaning stock');
GotoXY (1, 10); Write ('³StockNumber');
GotoXY (16, 10); Write ('Title');
GotoXY (36, 10); Write ('Description');
GotoXY (51, 10); Write ('Price');
GotoXY (59, 10); Write ('Status³');
While Not EoF (stock_file) Do
Begin
Read (stock_file, stockrecord);
If (stockrecord. status = 'A') Then
Begin
TextColor (White);
Begin
TextColor (Red);
GotoXY (1, Line); Write ('³');
End; {if statement}
TextColor (White);
GotoXY (4, Line); Write (stockrecord. stocknum);
GotoXY (16, Line); Write (stockrecord. title);
GotoXY (36, Line); Write (stockrecord. description);
GotoXY (51, Line); Write (stockrecord. price);
Begin
TextColor (Red);
GotoXY (65, Line); Write ('³');
End;
TextColor (White);
GotoXY (59, Line); Write (stockrecord. status);
Line := Line + 1;
numrec := numrec + 1;
If numrec = 10 Then
Repeat
Begin
TextColor (Red);
GotoXY (1, Line); Write ('ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ');
End;
CH := ReadKey;
If CH = #0 Then
Begin
CH := ReadKey;
If Ord (CH) = 81 Then
Begin
For Line := 12 To 21 Do
Begin
GotoXY (1, Line);
ClrEol
End;
Line := 11
End;
numrec := 0;
End;
Until Line = 11;
End;
End;
Begin
TextColor (Red);
GotoXY (1, Line); Write ('ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ');
End;
WriteLn;
WriteLn;
TextColor (Green);
GotoXY (10, 9);
WriteLn ('Press any key to return to Stock Menu');
anykey := ReadKey;
End; {procedure}
Procedure stock_menu;
{----!This section combines the other sections into a menu form----}
Var
option : Char;
count: Integer;
finished: boolean;
Begin
Assign (stock_file, 'a:\stock.txt');
Reset (stock_file);
finished:=false;
REPEAT
banner;
GotoXY (35 ,7); Write('Stock Menu');
GotoXY (30, 10); Write ('..[1]..Add New Stock');
GotoXY (30, 12); Write ('..[2]..View Stock Details');
GotoXY (30, 14); Write ('..[3]..Modify Stock Status');
GotoXY (30, 16); Write ('..[4]..View Current Stock');
GotoXY (30, 18); Write ('..[5]..View All Stock');
GotoXY (30, 20); Write ('..[6]..Return To Main Menu');
option := ReadKey;
Case option Of
'1' : add_stock;
'2' : view_stock;
'3' : password;
'4' : viewcurrent_stock;
'5' : viewall_stock;
'6' : finished:=true;
End; {case}
UNTIL finished;
End; {procedure}
Procedure modify_stock_status2;
{----!This section is restricted by a password, but once unlocked----}
{----!it has the ability to change the data stored on the file----}
Var
whichmod : Integer;
Begin
Assign (stock_file, 'a:\stock.txt');
Reset (stock_file);
banner;
GotoXY (30, 7); Write('Modify Stock Status');
GotoXY (20, 10); Write ('Which Stock (Type Stock Number): ');
TextColor (Red);
ReadLn (whichmod);
Seek (stock_file, whichmod);
Read (stock_file, stockrecord);
TextColor (White);
GotoXY(12, 14);
WriteLn ('Change status to Unavailable, Discontinued, Available: ');
GotoXY(28, 15); Write ('Please enter U D or A: ');
TextColor (Red);
ReadLn (stockrecord. status);
Seek (stock_file, whichmod);
Write (stock_file, stockrecord);
stock_menu;
End;
Procedure admin_menu;
{----!This section combines the other sections into a menu form----}
Var
option : Char;
Begin
ClrScr;
Repeat
banner;
GotoXY (35,7); Write('Admin Menu');
GotoXY (30, 10);
Write ('..[1]..Modify Stock');
GotoXY (30, 11);
Write ('..[2]..Change The Admin Password');
GotoXY (30, 12);
Write ('..[3]..Quit');
option := ReadKey;
Case option Of
'1' : modify_stock_status2;
'2' : change_password;
End; {case}
Until option = '3';
End; {procedure}
Procedure password2;
{----!This section is the password section which stop people----}
{----!accessing the modifying section without the correct password----}
Type
passwordrec = Record
passwd : String [10];
End;
Var
password_file : File Of passwordrec;
passwordrecord : passwordrec;
anykey : Char;
inpassword: String [10];
thekey: Char;
userpass: String [8];
password2 : String [10];
Begin
Assign (password_file, 'a:\password.txt');
Reset (password_file);
Read (password_file, passwordrecord);
Repeat
userpass := '';
banner;
GotoXY (20, 10);
TextBackground (Black);
TextColor (White);
Write ('Please enter the password for this section: ');
Repeat
thekey := ReadKey;
Write ('*');
If Ord (thekey) <> 13 Then userpass := userpass + thekey;
Until Ord (thekey) = 13;
Until userpass = passwordrecord. passwd;
admin_menu; ;
End;
BEGIN {main program}
finished:=false;
REPEAT
banner;
GotoXY(38,7); Write('Menu');
GotoXY (30, 10); Write ('..[1]..Stock');
GotoXY (30, 11); Write ('..[2]..Admin');
GotoXY (30, 12); Write ('..[3]..Members');
GotoXY (30, 13); Write ('..[4]..Quit');
option := ReadKey;
Case option Of
'1': stock_menu;
'2': admin_menu;
'3': members;
'4': finished:=true;
End; {case}
UNTIL finished;
End.
3 – Testing
3.1 – Test