Академический Документы
Профессиональный Документы
Культура Документы
INTRODUCTION TO C (CPG102)
Page
TABLE OF CONTENTS Chapter INTRODUCTION REQUIREMENTS SPECIFICATION PROGRAM SPECIFICATION SCREEN DESIGNS PROCESSING AND VALIDATION PROGRAM DESIGN TESTING IMPLEMENTATION CONCLUSION 5 6 7-18 19 20-163 169-178 179-194 195 PAGE 2-4
INTRODUCTION TO C (CPG102)
Page
Neoteric Nepal is one of the largest distributors for IT, communications and entertainment goods in Nepal. This organization is situated in Golchha House which is located at Ganabahal Street of Kathmandu City. This company contributes industrialization in the nation and was a key supporter of foreign business affairs. It is the first organization to use the new distribution procedures providing warranty and service arrangement. This company holds a history of high successes in supporting its brands like Nokia, Samsung, Dell, HP and other worldwide popular brands. It even provides high satisfaction to the consumers through its maintenance and replacement services of its products. Since its establishment, it has got a huge number of satisfied and loyal customers. It has huge market share of products with a network of many, computer and technology, wholesalers, outlets and shops around the country. Hence, it provides an excellent distribution arrangement to serve the consumers and delivers a money-making business schemes to its retailing partners. As per a discussion with Sanjay Golchha, the owner and the managing director, and Deepak Thapa, the sales officer of the company, Neoteric deals with variety of information technology and communications products such as computers, laptops, mobile, telephones, display and storage devices, printing and imaging products, networking devices, entertainment and power management systems too and service oriented repair centre. Neoterics width of achievement across the Nepali market is matchless, and it operates on financially practicable ideology. Its quick development and high monetary effectiveness makes it an ultimate business associate, and is dedicated for the endurance to the countrys economy, its partners and customers.
INTRODUCTION TO C (CPG102)
Page
Current System
The study of the companys current system shows that they are using an old stock management system, used since the establishment of the business. According to the staffs of the company, the system is very difficult to understand, use and consumes too much time. In the present context of the business, the company has to perform so many business activities that are needed to be recorded into the database. But different tasks done in different software is a difficult way of management for them. For instance, they use different software systems to view, add or remove stocks; to keep purchase and sales records. This proved to be very time consuming for staffs. So they wanted a new single software system that was easier and could handle all those tasks within it.
Problem Background
According to the study of the current system, different problems were found out which are listed below: 1) Different software is used for different task that made the work more time and resources consuming. 2) The staffs needed to study each of the software individually that created a lot of confusion and made it difficult for them to understand and memorize them thoroughly. 3) Different types of items were recorded under same category that made it difficult for them to search an individual product.
INTRODUCTION TO C (CPG102)
Page
REQUIREMENTS SPECIFICATION
Proposal of new System: Stock Management System for Neoteric Nepal Aim: The main aim of new system is to create an easier and safer interface of business management system. Objective: To help in effective management with add, search, update and removal features of the products through a single system interface.
INTRODUCTION TO C (CPG102)
Page
PROGRAM SPECIFICATION
Input Specification
S. No. 1. 2. 3. 4. Input Variable Company Model Price Quantity It denotes the name of products company. It denotes the model no. of the product. It indicates the price of the product. It indicates the quantity or number of the product. 50 50 50 50 Description Size(bytes) Data Type String String String String
File Specification
S. No.
Description
File name
File Type
1. 2. 3. 4. 5.
fp fp fp fp ft
It holds the laptop details to be recorded. It holds the cellphone details to be recorded. It holds the accessories details to be recorded. It holds the accessories details to be recorded. It holds the temporary details entered.
INTRODUCTION TO C (CPG102)
Page
Details Student ID: Name: Submitted To: Course Name: Module Name: Term:
Info
INTRODUCTION TO C (CPG102)
Info
INTRODUCTION TO C (CPG102)
Page
Main Menu
1. Manage Laptops
2. Manage Cellphones
3. Manage Accessories
4. Manage Parts
5. Log Out
e. Exit
Info
Press Option(1/2/3/4/5/e):
INTRODUCTION TO C (CPG102)
Page
Manage Parts
1. Add Parts
2. Search/List Parts
3. Update Parts
4. Delete Parts
5. Menu
Press Option(1/2/3/4/5):
INTRODUCTION TO C (CPG102)
Page
10
Add Record
Details Company:
Model:
Price(Rs.):
Quantiy:
ADD
RESET
CANCEL
INTRODUCTION TO C (CPG102)
Page
11
Search/List Record
Company:
Model:
SEARCH
CANCEL
INTRODUCTION TO C (CPG102)
Page
12
Update Record
Company:
Model:
Price:
Quantity:
Update
Cancel
INTRODUCTION TO C (CPG102)
Page
13
Delete Record
Company:
Model:
DELETE
CANCEL
INTRODUCTION TO C (CPG102)
Page
14
Output Screenshots
Splash Screen
Authentication Screen
INTRODUCTION TO C (CPG102)
Page
15
Main Menu
Manage Screen
INTRODUCTION TO C (CPG102)
Page
16
Add Screen
Search/List Screen
INTRODUCTION TO C (CPG102)
Page
17
Update Screen
Delete Screen
INTRODUCTION TO C (CPG102)
Page
18
1) Authentication Username and password are provided in the system for authentication so that the records can be kept safe and secure from loss and theft. 2) Add/remove Laptops, Cellphones, Accessories and Parts can be recorded with the details of their company, model, price and quantity or removed when required. 3) Increase or decrease The quantity and price of every record can be increased or decreased according to the purchase or sales done. 4) Search The records can be searched according to their company and model which generates the required result if they match the added records.
Validation
1) Authentication username and password must be entered with same cases (Uppercase or lowercase) as validated. 2) Model of products must be unique for same company. 3) Company and model of the products must contain minimum of single character and company must be entered with block letters (Uppercase). 4) Both company and model should match the record while searching, updating or deleting the record. 5) Special characters shouldnt be used in authentication. 6) Only dot (.) can be used to enter product price.
Page
INTRODUCTION TO C (CPG102)
19
MODULE SPLASH
DO DISPLAY STOCK MANAGEMENT SYSTEM DISPLAY NEOTERIC NEPAL DISPLAY DETAILS DISPLAY STUDENT NAME: DISPLAY ID: DISPLAY SUBMITTED TO: DISPLAY COURSE NAME: DISPLAY MODULE NAME: DISPLAY TERM: DISPLAY INFO DISPLAY PRESS ANY KEY TO CONTINUE. DISPLAY BIRAT LAL SHRESTHA DISPLAY 1801T3100045 DISPLAY INFORMATICS COLLEGE
DISPLAY IDITC
INTRODUCTION TO C (CPG102)
Page
20
DISPLAY T1 END DO
MODULE AUTHENTICATION
DO FOR I EQUALS TO 0, i LESSER THAN OR EQUALS TO 3, INCREASE i by 1 DO DISPLAY AUTHENTICATION REQUIRED DISPLAY USERNAME: DISPLAY PASSWORD: DISPLAY INFO INPUT username INPUT password IF username = birat AND password= birat DO BREAK END DO ELSE DO DISPLAY INVALID USERNAME OR PASSWORD ENTERED!
END DO
INTRODUCTION TO C (CPG102)
Page
21
END IF END DO END FOR IF i LESS THAN OR EQUALS TO 3 DO CALL menu END DO ELSE DO DISPLAY NO AUTHENTICATION ATTEMPT LEFT. TRY NEXT TIME! EXIT END DO END IF END DO
DO count EQUALS TO 0 DO DO
INTRODUCTION TO C (CPG102)
Page
22
GET in
DO BREAK END DO ELSE IF in EQUALS TO 8 AND count GREATER THAN 0 DO DISPLAY 8,32,8 DECREASE count BY 2 END DO ELSE IF in EQUALS TO 27 DO CALL splash END DO ELSE IF in NOT EQUALS TO 13 AND in NOT EQUALS TO 8 AND in NOT EQUALS TO 27 DO input[count] EQUALS TO in DISPLAY * END DO ELSE DO CONTINUE END DO END IF
INTRODUCTION TO C (CPG102)
Page
23
INCREASE count BY 1
DO count EQUALS TO 0 DO DO GET in IF in EQUALS TO 13 AND count GREATER THAN 0 DO BREAK END DO ELSE IF in EQUALS TO 8 AND count GREATER THAN 0 DO DISPLAY 8,32,8 DECREASE count by2 END DO ELSE IF in EQUALS TO 27
CALL splash
INTRODUCTION TO C (CPG102)
Page
24
DO
END DO ELSE IF in NOT EQUALS TO 13 AND in NOT EQUALS TO 8 AND in TO 27 DO input[count] EQUALS TO in DISPLAY input[count] END DO ELSE DO CONTINUE END DO END IF INCREASE count BY 1 UNTILL count LESS THAN 50 input[count] EQUALS TO 0 STRING COPY input ENDDO NOT EQUALS
MODULE MENU
INTRODUCTION TO C (CPG102)
Page
DO
25
DO
DISPLAY MAIN MENU DISPLAY 1. MANAGE LAPTOPS DISPLAY 2. MANAGE CELLPHONES DISPLAY 3. MANAGE ACCESSORIES DISPLAY 4. MANAGE PARTS DISPLAY 5. LOG OUT DIPSLAY E. EXIT DISPLAY PRESS OPTION (1/2/3/4/5/6/E): DISPLAY INFO GET choice IF choice NOT EQUALS 1 AND choice NOT EQUALS 2 AND choice NOT EQUALS 3 AND choice NOT EQUALS 4 AND choice NOT EQUALS 5 AND choice NOT EQUALS E DO DISPLAY INVALID OPTION END DO END IF UNTIL choice NOT EQUALS TO E DO CASE choice 1 DO CALL manageLaps END DO choice 2 DO CALL manageCells
INTRODUCTION TO C (CPG102)
Page
26
END DO choice '3' DO CALL manageAccessories END DO choice '4 DO CALL manageParts END DO choice '5' DO CALL authentication END DO choice 'e' DO DISPLAY SEE YOU SOON! EXIT END DO
MODULE MANAGELAPS
INTRODUCTION TO C (CPG102)
Page
27
DO DO DISPLAY MANAGE LAPTOPS DISPLAY 1.ADD LAPTOPS DISPLAY 2.LIST/SEARCH LAPTOPS DISPLAY 3.UPDATE LAPTOPS DISPLAY 4.DELETE LAPTOPS DISPLAY 5.MENU DISPLAY PRESS MENU (1/2/3/4/5): DISPLAY INFO GET choice IF choice NOT EQUALS 1 AND choice NOT EQUALS 2 AND choice NOT EQUALS 3 AND choice NOT EQUALS 4 AND choice NOT EQUALS 5 DO DISPLAY "INVALID OPTION!" END DO END IF UNTIL choice NOT EQUALS TO 5 DO CASE choice 1 DO CALL addLaps
INTRODUCTION TO C (CPG102)
Page
choice 2
28
END DO
DO CALL searchListLaps END DO choice '3' DO CALL updateLaps END DO choice '4 DO CALL deleteLaps END DO choice '5' DO CALL menu END DO END CASE END DO
MODULE ADDLAPS
INTRODUCTION TO C (CPG102)
Page
29
DISPLAY DETAILS DISPLAY COMPANY: DISPLAYMODEL: DISPLAY PRICE (RS.): DISPLAY QUANTITY: DISPLAY ADD DISPLAY RESET DISPLAY CANCEL DISPLAY INFO DISPLAY PRESS ENTER TO ADD/ R TO RESET/ C TO CANCEL
INPUT lapCompany INPUT lapModel INPUT lapPrice INPUT lapQuantity GET add IF add EQUALS TO r OR add EQUALS TO R DO CALL addLaps END DO ELSE IF add EQUALS TO 'c' OR add EQUALS TO 'C' DO CALL menu
END IF
INTRODUCTION TO C (CPG102)
Page
30
END DO
OPEN FILE Laptops.dat IF fp EQUALS TO NULL DO DISPLAY FILE NOT FOUND!" CALL menu END DO ELSE DO WRITE laptop CLOSE fp END DO END IF DISPLAY "THE LAPTOP WAS SUCCESSFULLY RECORDED!" DISPLAY "ADD ANOTHER RECORD? (Y/N)" GET exit IF exit EQUALS TO 'y' OR exit EQUALS TO 'Y' DO CALL addLaps END DO ELSE DO CALL menu END DO
END DO
INTRODUCTION TO C (CPG102)
Page
31
END IF
MODULE SEARCHLISTLAPS
DO y EQUALS TO 7 flag EQUALS TO 0 CREATE FILE *fp DISPLAY LIST/SEARCH LAPTOPS DISPLAY COMPANY: DISPLAY MODEL: DISPLAY SEARCH DISPLAY CANCEL DISPLAY INFO DISPLAY PRESS ENTER TO SEARCH/ C TO CANCEL GET getch()
INPUT input INPUT input1 IF getch() EQUALS TO 'C' OR getch() EQUALS TO c' DO
END DO
INTRODUCTION TO C (CPG102)
Page
32
CALL menu
END IF DISPLAY SHOW SEARCH DISPLAY COMPANY DISPLAY MODEL DISPLAY PRICE DISPLAY QUANTITY DISPLAY INFO FILE OPEN Laptops.dat IF fp EQUALS NULL DO DISPLAY "FILE NOT FOUND!" CALL menu END DO END IF
WHILE READ laptop NOT EQUALS TO 0 DO IF STRING COMPARE laptop DO flag EQUALS 1 DISPLAY laptop lapCompany DISPLAY laptop lapModel DISPLAY laptop lapPrice
INTRODUCTION TO C (CPG102)
Page
INCREASE y BY 1
33
END DO END IF END DO END WHILE CLOSE fp IF flag EQUALS 0 DO DISPLAY Record not found! END DO END IF CLOSE fp DISPLAY Press any key to go to menu. CALL menu END DO
MODULE UPDATELAPS
DISPLAY MODEL:
INTRODUCTION TO C (CPG102)
Page
34
DISPLAY COMPANY:
DISPLAY PRICE: DISPLAY QUANTITY: DISPLAY UPDATE DISPLAY CANCEL DISPLAY INFO DISPLAY "PRESS ENTER TO UPDATE/ C TO CANCEL" INPUT input INPUT input1 OPEN FILE Laptops.dat IF fp EQUALS TO NULL DO DISPLAY FILE NOT FOUND! CALL menu END DO END IF WHILE READ laptop NOT EQUALS TO 0 DO IF STRING COMPARE laptop lapCompany EQUALS TO 0 AND laptop lapModel EQUALS TO 0 DO flag EQUALS TO 1 BREAK END DO
INTRODUCTION TO C (CPG102)
Page
END DO
35
END IF
END WHILE IF flag EQUALS TO 0 DO DISPLAY Record not found! CALL menu END DO END IF DISPLAY UPDATE THE RECORD? (Y/N) GET YESNO IF YESNO EQUALS TO 'y' OR YESNO EQUALS TO 'Y' DO INPUT laptop lapPrice INPUT laptop lapQuantity SEEK FILE WRITE FILE laptop END DO ELSE DO CALL menu END DO END IF CLOSE fp DISPLAY "RECORD UPDATED SUCCESSFULLY!
CALL menu
INTRODUCTION TO C (CPG102)
Page
36
END DO
MODULE DELETELAPS
DO CREATE FILE *fp,*ft Y EQUALS TO 12 Flag EQUALS TO 0 DISPLAY DELETE LAPTOPS DISPLAY COMPANY: DISPLAY MODEL: DISPLAY DELETE DISPLAY CANCEL DISPLAY INFO DISPLAY PRESS ENTER TO DELETE/ C TO CANCEL INPUT input INPUT input1 GET add IF add EQUALS TO 'c' OR add EQUALS TO 'C' DO
END DO
INTRODUCTION TO C (CPG102)
Page
37
CALL menu
END IF
fp EQUALS TO fopen "Laptops.dat" IF fp EQUALS TO NULL DO DISPLAY FILE NOT FOUND! CALL menu EXIT END DO END IF WHILE READ laptop NOT EQUALS TO 0 DO IF STRING COMPARE laptop lapCompany EQUALS TO 0 AND laptop lapModel EQUALS TO 0 DO flag EQUALS TO 1 DISPLAY laptop lapCompany
INTRODUCTION TO C (CPG102)
Page
INCREASE y BY 1
38
BREAK END DO END IF END DO END WHILE IF flag EQUALS TO 0 DO DISPLAY "Record not found!" CALL menu END DO END IF DISPLAY DELETE THE RECORD? (Y/N) GET YESNO IF YESNO EQUALS TO 'y' OR YESNO EQUALS TO Y' DO ft EQUALS TO fopen "temp.dat" WHILE READ laptop DO IF STRING COMPARE laptop lapModel EQUALS TO 0 DO WRITE laptop END DO END DO
CLOSE fp
INTRODUCTION TO C (CPG102)
Page
39
END WHILE
CLOSE ft REMOVE Laptops.dat RENAME temp.dat TO Laptops.dat DISPLAY RECORD DELETED SUCCESSFULLY! CALL menu END DO ELSE DO DISPLAY RECORD NOT DELETED! CALL menu END DO END IF END DO
INTRODUCTION TO C (CPG102)
Page
40
PROGRAMMING CODE
void splash();//prototype declaration for splash screen void authentication();//prototype declaration for authentication screen void menu();//prototype declaration for main menu screen void manageLaps();//prototype declaration for manage laptops screen void addLaps();//prototype declaration for add laptops screen void searchListLaps();//prototype declaration for list/search laptops screen void updateLaps();//prototype declaration for update laptops screen void deleteLaps();//prototype declaration for delete laptops screen void manageCells();//prototype declaration for manage cellphones screen void addCells();//prototype declaration for add cellphones screen void searchListCells();//prototype declaration for list/search cellphones screen void updateCells();//prototype declaration for update cellphones screen void deleteCells();//prototype declaration for delete cellphones screen void manageAccessories();//prototype declaration for manage accessories screen void addAccessories();//prototype declaration for add accessories screen void searchListAccessories();//prototype declaration for list/search accessories screen void updateAccessories();//prototype declaration for update accessories screen
INTRODUCTION TO C (CPG102)
Page
41
void addParts();//prototype declaration for add parts screen void searchListParts();//prototype declaration for list/search parts screen void updateParts();//prototype declaration for update parts screen void deleteParts();//prototype declaration for delete parts screen void scanUsername(char *);//function define for username scan void scanPassword(char *);//function define for password scan void scanCompany(char *);//function define for company scan void scanModel(char *);//function define for model scan void scanPrice(char *);//function define for price scan void scanQuantity(char *);//function define for quantity scan void makeBox(int, int, int, int);//prototype declaration for making boxes
//########################STRUCT DECLARATION############################// struct Laptops { char lapCompany[50]; char lapModel[50]; char lapPrice[50]; char lapQuantity[50]; }laptop;
struct Cells
INTRODUCTION TO C (CPG102)
Page
char cellCompany[50];
42
struct Accessories { char accCompany[50]; char accModel[50]; char accPrice[50]; char accQuantity[50]; }access;
struct Parts { char partCompany[50]; char partModel[50]; char partPrice[50]; char partQuantity[50]; }part;
INTRODUCTION TO C (CPG102)
Page
43
//####################SPLASH SCREEN##########################//
void splash() {
textbackground(BLACK); clrscr();
makeBox(20,5,40,3);
INTRODUCTION TO C (CPG102)
Page
44
makeBox(19,4,42,4);
textcolor(YELLOW); makeBox(20,36,40,5); gotoxy(20,35); cprintf("Info"); gotoxy(27,5); cprintf(" STOCK MANAGEMENT SYSTEM "); gotoxy(32,7); cprintf(" NEOTERIC NEPAL"); textcolor(CYAN); makeBox(19,21,42,7); textcolor(LIGHTBLUE); makeBox(18,20,44,9); makeBox(33,19,12,2); textcolor(YELLOW); gotoxy(36,20); cprintf("Details"); textcolor(YELLOW); gotoxy(21,22); cprintf("Student Name: "); gotoxy(21,23); cprintf("ID: "); gotoxy(21,24); cprintf("Submitted To: ");
INTRODUCTION TO C (CPG102)
Page
45
gotoxy(21,25);
textcolor(WHITE); gotoxy(35,22); cprintf("Birat Lal Shrestha"); gotoxy(35,23); cprintf("1801T3100045"); gotoxy(35,24); cprintf("Informatics College"); gotoxy(35,25); cprintf("CPG102 (Introduction to C)"); gotoxy(35,26); cprintf("IDITC"); gotoxy(35,27); cprintf("T1");
getch();
INTRODUCTION TO C (CPG102)
Page
46
_setcursortype(_NOCURSOR);
authentication();
//#######################AUTHENTICATION############################//
void authentication() {
char input;
makeBox(2,2,77,47);
INTRODUCTION TO C (CPG102)
Page
47
textcolor(DARKGRAY);
textcolor(RED); gotoxy(28,18); cprintf("AUTHENTICATION REQUIRED"); textcolor(YELLOW); gotoxy(28,21); cprintf("Username: "); gotoxy(28,23); cprintf("Password: "); gotoxy(20,35); cprintf("Info");
fflush(stdin);
INTRODUCTION TO C (CPG102)
Page
48
gotoxy(38,23);
//scanf("%s",password);
scanPassword(password);
if(stricmp(username,"birat")==0 && stricmp(password,"birat")==0) { break; } else { textcolor(WHITE); gotoxy(22,37); cprintf("Invalid Username or Password entered!"); gotoxy(32,38); cprintf("Attempts Left: %d", 3-i); getch(); } }
if(i<=3)
menu();
INTRODUCTION TO C (CPG102)
Page
49
//clrscr(); } else { clrscr(); gotoxy(18,10); textcolor(GREEN); cprintf("No authentication attempt left. Try next time!"); getch(); exit(0); }
getch();
clrscr();
INTRODUCTION TO C (CPG102)
Page
50
textcolor(WHITE); gotoxy(34,5); cprintf("Main Menu"); textcolor(WHITE); gotoxy(10,12); cprintf("1. Manage Laptops"); gotoxy(10,16); cprintf("2. Manage Cells"); gotoxy(10,20); cprintf("3. Manage Accessories"); gotoxy(10,24); cprintf("4. Manage Parts"); gotoxy(10,28); cprintf("5. Log Out"); gotoxy(10,32); cprintf("e. Exit");
gotoxy(28,41);
INTRODUCTION TO C (CPG102)
Page
51
textcolor(WHITE);
cprintf("Press Option(1/2/3/4/5/e):"); textcolor(WHITE); gotoxy(20,39); cprintf("Info"); _setcursortype(_SOLIDCURSOR); gotoxy(55,41); fflush(stdin); choice=getche(); getch(); textcolor(YELLOW); if(choice!='1' && choice!='2' && choice!='3' && choice!='4' && choice!='5' && choice!='e')//entering choices {
gotoxy(35,43); printf("Invalid Option"); getch(); } }while(choice!='1' && choice!='2' && choice!='3' && choice!='4' && choice!='5' && choice!='e'); clrscr(); switch(choice)//cases for choices { case '1': { manageLaps();
INTRODUCTION TO C (CPG102)
Page
52
}break; case '2': { manageCells(); }break; case '3': { manageAccessories(); }break; case '4': { manageParts(); }break; case '5': { authentication(); }break; case 'e': { clrscr(); gotoxy(33,10); textcolor(WHITE); cprintf("See You Soon!");
exit(0);
INTRODUCTION TO C (CPG102)
Page
53
getch();
void manageLaps() { char insChoice; do { clrscr(); textcolor(DARKGRAY); makeBox(2,2,77,47); textcolor(YELLOW); makeBox(20,40,40,5); makeBox(32,4,17,2); makeBox(6,10,69,20); textcolor(WHITE); gotoxy(34,5); cprintf("Manage Laptops");
INTRODUCTION TO C (CPG102)
Page
textcolor(WHITE);
54
textcolor(WHITE);
gotoxy(10,12); cprintf("1. Add Laptops"); gotoxy(10,16); cprintf("2. Search\List Laptops"); gotoxy(10,20); cprintf("3. Update Laptops"); gotoxy(10,24); cprintf("4. Delete Laptops"); gotoxy(10,28); cprintf("5. Menu"); textcolor(WHITE); gotoxy(20,39); cprintf("Info"); textcolor(WHITE); gotoxy(28,41); cprintf("Press Option(1/2/3/4/5):"); gotoxy(53,41); fflush(stdin); insChoice=getche(); getch();
INTRODUCTION TO C (CPG102)
Page
gotoxy(35,43);
55
cprintf("Invalid Option!"); getch(); } }while(insChoice!='1' && insChoice!='2' && insChoice!='3' && insChoice!='4' && insChoice!='5'); clrscr(); switch(insChoice) { case '1': { addLaps(); }break; case '2': { searchListLaps(); }break; case '3': { updateLaps(); }break; case '4': { deleteLaps();
INTRODUCTION TO C (CPG102)
Page
case '5':
56
}break;
//#########################ADD LAPTOPS############################// void addLaps() { FILE *fp; long int size; char add; char exit; size=sizeof(laptop);
makeBox(2,2,77,47);
INTRODUCTION TO C (CPG102)
Page
57
textcolor(DARKGRAY);
textcolor(WHITE); gotoxy(34,5); cprintf("Add Laptops"); gotoxy(11,14); cprintf("Details"); gotoxy(11,16); cprintf("Company:"); gotoxy(11,20); cprintf("Model: "); gotoxy(11,24); cprintf("Price(Rs.): "); gotoxy(11,28); cprintf("Quantity: "); textcolor(YELLOW); gotoxy(20,32); cprintf("Add"); gotoxy(40,32); cprintf("Reset"); gotoxy(60,32); cprintf("Cancel"); textcolor(WHITE); gotoxy(20,39);
gotoxy(20,41);
INTRODUCTION TO C (CPG102)
Page
58
cprintf("Info");
//scanning values from user gotoxy(31,16); _setcursortype(_SOLIDCURSOR); fflush(stdin); scanCompany(laptop.lapCompany); gotoxy(31,20); fflush(stdin); scanModel(laptop.lapModel); gotoxy(31,24); fflush(stdin); scanPrice(laptop.lapPrice); gotoxy(31,28); fflush(stdin); scanQuantity(laptop.lapQuantity);
_setcursortype(_NOCURSOR);
addLaps();
INTRODUCTION TO C (CPG102)
Page
59
fp=fopen("Laptops.dat","ab+");
if(fp==NULL) // if the file couldn't be opened { textcolor(YELLOW); gotoxy(29,43); cprintf("File not found!"); getch(); menu(); }
INTRODUCTION TO C (CPG102)
Page
60
gotoxy(23,42); textcolor(YELLOW); cprintf("The laptop was successfully recorded!"); gotoxy(29,43); cprintf("Add another record? (Y/N)"); exit=getch(); if(exit=='y' || exit=='Y')//decision for new data input { addLaps(); } else { menu(); }
//#########################SEARCH/LIST LAPTOPS####################//
int flag=0;
INTRODUCTION TO C (CPG102)
Page
61
char input[50]; char input1[50]; long int size=sizeof(laptop); clrscr(); textcolor(YELLOW); makeBox(20,40,40,5); makeBox(32,4,22,2); makeBox(6,12,69,8); textcolor(DARKGRAY); makeBox(2,2,77,47);
textcolor(WHITE); gotoxy(34,5); cprintf("Search/List Laptops"); gotoxy(8,14); cprintf("Company: "); gotoxy(8,18); cprintf("Model: "); textcolor(YELLOW); gotoxy(25,32); cprintf("Search"); gotoxy(48,32); cprintf("Cancel");
textcolor(WHITE);
INTRODUCTION TO C (CPG102)
Page
62
gotoxy(20,39);
textcolor(WHITE);
INTRODUCTION TO C (CPG102)
Page
63
gotoxy(34,5);
gotoxy(30,9); cprintf("Model");
gotoxy(45,9); cprintf("Price");
gotoxy(60,9); cprintf("Quantity");
fp=fopen("Laptops.dat","rb+");
getch();
INTRODUCTION TO C (CPG102)
Page
64
menu(); }
while(fread(&laptop,size,1,fp)!=0) //fread returning zero means, the file has reached the end {
&&
textcolor(YELLOW);
gotoxy(15,12); cprintf("%s",laptop.lapCompany);
gotoxy(30,12); cprintf("%s",laptop.lapModel);
gotoxy(45,12); cprintf("%s",laptop.lapPrice);
INTRODUCTION TO C (CPG102)
Page
65
} }
if(flag==0) // if the record was not found { gotoxy(30,43); textcolor(YELLOW); cprintf("Record not found!"); }
fclose(fp);
getch(); menu();
} //############################UPDATE LAPTOPS##########################//
INTRODUCTION TO C (CPG102)
Page
66
void updateLaps()
FILE *fp; int flag=0; char input[50]; char input1[50]; char yesno; long int size=sizeof(laptop); clrscr(); textcolor(YELLOW); makeBox(20,40,40,5); makeBox(32,4,17,2); makeBox(6,10,69,8); makeBox(6,24,69,8); textcolor(DARKGRAY); makeBox(2,2,77,47);
textcolor(WHITE); gotoxy(34,5); cprintf("Update Laptops"); gotoxy(10,12); cprintf("Company: "); gotoxy(10,16); cprintf("Model: ");
cprintf("Price: ");
INTRODUCTION TO C (CPG102)
Page
67
gotoxy(10,26);
gotoxy(10,30); cprintf("Quantity: "); textcolor(YELLOW); gotoxy(25,34); cprintf("Update"); gotoxy(48,34); cprintf("Cancel"); textcolor(WHITE); gotoxy(20,39); cprintf("Info"); gotoxy(23,41); textcolor(YELLOW); cprintf("Press ENTER to Update/ C to Cancel"); gotoxy(34,12); scanCompany(input); gotoxy(34,16); scanModel(input1);
_setcursortype(_NOCURSOR);
fp=fopen("Laptops.dat","rb+");
textcolor(YELLOW);
INTRODUCTION TO C (CPG102)
Page
68
gotoxy(16,42); cprintf("File not found!"); getch(); menu(); } while(fread(&laptop,size,1,fp)!=0) //fread returning zero means, the file has reached the end {
&&
break; } }
if(flag==0) // if the record was not found { gotoxy(24,42); textcolor(YELLOW); cprintf("Record not found!"); getch();
INTRODUCTION TO C (CPG102)
Page
69
menu();
//scanning the values from user _setcursortype(_SOLIDCURSOR); gotoxy(34,26); fflush(stdin); scanPrice(laptop.lapPrice); gotoxy(34,30); fflush(stdin); scanQuantity(laptop.lapQuantity);
INTRODUCTION TO C (CPG102)
Page
70
fseek(fp,-size,SEEK_CUR);
} else { menu(); }
fclose(fp);
getch(); menu();
INTRODUCTION TO C (CPG102)
Page
71
//###########################DELETE LAPTOPS############################// void deleteLaps() { FILE *fp,*ft; int y=12; int flag=0; char input[50]; char input1[50]; char add; char yesno; long int size; size=sizeof(laptop); clrscr(); textcolor(YELLOW); makeBox(20,40,40,5); makeBox(32,4,17,2); makeBox(6,19,69,6); textcolor(DARKGRAY); makeBox(2,2,77,47);
textcolor(WHITE);
cprintf("Delete Laptops");
INTRODUCTION TO C (CPG102)
Page
72
gotoxy(34,5);
gotoxy(10,20); cprintf("Company: "); gotoxy(10,24); cprintf("Model: "); textcolor(YELLOW); gotoxy(25,34); cprintf("Delete"); gotoxy(48,34); cprintf("Cancel"); textcolor(WHITE); gotoxy(20,39); cprintf("Info"); textcolor(YELLOW); gotoxy(23,41); cprintf("Press ENTER to Delete/ C to Cancel"); _setcursortype(_SOLIDCURSOR); gotoxy(25,20); fflush(stdin); scanCompany(input); gotoxy(25,24); fflush(stdin); scanModel(input1);
add=getch();
INTRODUCTION TO C (CPG102)
Page
73
_setcursortype(_NOCURSOR);
textcolor(YELLOW);
gotoxy(50,9);
INTRODUCTION TO C (CPG102)
Page
74
cprintf("Model");
if(fp==NULL) //if anycase the file cannot be opened { gotoxy(16,42); textcolor(RED); cprintf("File not found!"); getch(); menu(); exit(0);
INTRODUCTION TO C (CPG102)
Page
gotoxy(25,y);
75
cprintf("%s",laptop.lapCompany);
gotoxy(50,y); cprintf("%s",laptop.lapModel);
y++; //print every new records in the new line break; } } if(flag==0) //if the record was not found { //show error message gotoxy(27,43); textcolor(YELLOW); cprintf("Record not found!"); getch(); menu(); } gotoxy(27,42); textcolor(YELLOW); cprintf("Delete the record? (y/n)"); fflush(stdin); yesno=getche();
INTRODUCTION TO C (CPG102)
Page
76
if(yesno=='y' || yesno=='Y')
//to copy every record from original to temp except the record to be deleted. while(fread(&laptop,size,1,fp)!=0) { if(stricmp(laptop.lapModel,input1)!=0) { fwrite(&laptop,size,1,ft); //write every record into temp.dat } } fclose(fp); fclose(ft);
gotoxy(25,43); textcolor(GREEN);
getch();
INTRODUCTION TO C (CPG102)
Page
77
menu();
//##########################MANAGE CELLS##############################//
makeBox(32,4,21,2);
INTRODUCTION TO C (CPG102)
Page
78
makeBox(20,40,40,5);
textcolor(WHITE); gotoxy(34,5); cprintf("Manage Cell Phones"); textcolor(WHITE); textcolor(WHITE); gotoxy(10,12); cprintf("1. Add Cell Phones"); gotoxy(10,16); cprintf("2. List/Search Cell Phones"); gotoxy(10,20); cprintf("3. Update Cell Phones"); gotoxy(10,24); cprintf("4. Delete Cell Phones"); gotoxy(10,28); cprintf("5. Menu"); textcolor(WHITE); gotoxy(20,39); cprintf("Info"); textcolor(WHITE);
cprintf("Press Option(1/2/3/4/5):");
INTRODUCTION TO C (CPG102)
Page
79
gotoxy(28,41);
if(insChoice!='1' && insChoice!='2' && insChoice!='3' && insChoice!='4' && insChoice!='5') { gotoxy(35,43); cprintf("Invalid Option!"); getch(); } }while(insChoice!='1' && insChoice!='2' && insChoice!='3' && insChoice!='4' && insChoice!='5'); clrscr(); switch(insChoice) { case '1': { addCells(); }break; case '2': { searchListCells(); }break; case '3':
INTRODUCTION TO C (CPG102)
Page
80
{ updateCells(); }break; case '4': { deleteCells(); }break; case '5': { menu(); }break; } getch(); }
//#########################ADD CELLPHONES############################// void addCells() { FILE *fp; long int size; char add; char exit;
INTRODUCTION TO C (CPG102)
Page
81
size=sizeof(cell);
textcolor(WHITE); gotoxy(34,5); cprintf("Add Cellphones"); gotoxy(11,14); cprintf("Details"); gotoxy(11,16); cprintf("Company:"); gotoxy(11,20); cprintf("Model: "); gotoxy(11,24); cprintf("Price(Rs.): "); gotoxy(11,28); cprintf("Quantity: "); textcolor(YELLOW);
cprintf("Add");
INTRODUCTION TO C (CPG102)
Page
82
gotoxy(20,32);
gotoxy(40,32); cprintf("Reset"); gotoxy(60,32); cprintf("Cancel"); textcolor(WHITE); gotoxy(20,39); cprintf("Info"); gotoxy(20,41); textcolor(YELLOW); cprintf("Press ENTER to ADD/ R to RESET/ C to CANCEL"); textcolor(YELLOW);
//scanning values from user gotoxy(31,16); _setcursortype(_SOLIDCURSOR); fflush(stdin); scanCompany(cell.cellCompany); gotoxy(31,20); fflush(stdin); scanModel(cell.cellModel); gotoxy(31,24); fflush(stdin); scanPrice(cell.cellPrice);
fflush(stdin);
INTRODUCTION TO C (CPG102)
Page
83
gotoxy(31,28);
scanQuantity(cell.cellQuantity);
_setcursortype(_NOCURSOR);
add=getch(); if(add=='r' || add=='R')//used to reset the window { addCells(); } else if(add=='c' || add=='C')//go back to main menu after cancelling { menu(); }
fp=fopen("Cells.dat","ab+");
if(fp==NULL) // if the file couldn't be opened { textcolor(YELLOW); gotoxy(29,43); cprintf("File not found!"); getch(); menu();
INTRODUCTION TO C (CPG102)
Page
84
gotoxy(22,42); textcolor(YELLOW); cprintf("The cellphone was successfully recorded!"); gotoxy(29,43); cprintf("Add another record? (Y/N)"); exit=getch(); if(exit=='y' || exit=='Y')//decision for new data input { addCells(); } else { menu(); }
INTRODUCTION TO C (CPG102)
Page
85
//#########################SEARCH/LIST CELLPHONES####################//
int flag=0; char input[50]; char input1[50]; long int size=sizeof(cell); clrscr(); textcolor(YELLOW); makeBox(20,40,40,5); makeBox(32,4,25,2); makeBox(6,12,69,8); textcolor(DARKGRAY); makeBox(2,2,77,47);
gotoxy(8,18);
INTRODUCTION TO C (CPG102)
Page
86
cprintf("Company: ");
cprintf("Model: "); textcolor(YELLOW); gotoxy(25,32); cprintf("Search"); gotoxy(48,32); cprintf("Cancel"); gotoxy(20,39); textcolor(WHITE); cprintf("Info"); textcolor(YELLOW); gotoxy(23,41); cprintf("Press ENTER to Search/ C to Cancel");
clrscr();
INTRODUCTION TO C (CPG102)
Page
87
textcolor(DARKGRAY); makeBox(2,2,77,47); textcolor(YELLOW); makeBox(10,7,60,30); makeBox(30,4,18,2); makeBox(20,40,40,5); gotoxy(34,5); textcolor(WHITE); cprintf("Show Search"); gotoxy(20,39); textcolor(WHITE); cprintf("Info"); //statics tile gotoxy(15,9); cprintf("Company");
gotoxy(30,9); cprintf("Model");
gotoxy(45,9); cprintf("Price");
gotoxy(60,9);
INTRODUCTION TO C (CPG102)
Page
88
cprintf("Quantity");
fp=fopen("Cells.dat","rb+");
if(fp==NULL) // if the file couldn't be opened { textcolor(YELLOW); gotoxy(30,43); cprintf("File not found!"); getch(); menu(); }
while(fread(&cell,size,1,fp)!=0) //fread returning zero means, the file has reached the end {
&&
textcolor(YELLOW);
gotoxy(15,12); cprintf("%s",cell.cellCompany);
INTRODUCTION TO C (CPG102)
Page
gotoxy(30,12);
89
cprintf("%s",cell.cellModel);
gotoxy(45,12); cprintf("%s",cell.cellPrice);
if(flag==0) // if the record was not found { gotoxy(30,43); textcolor(YELLOW); cprintf("Record not found!"); }
fclose(fp);
textcolor(YELLOW); gotoxy(25,41);
INTRODUCTION TO C (CPG102)
Page
90
getch(); menu();
} //############################UPDATE CELLPHONES##########################//
void updateCells() {
FILE *fp; int flag=0; char input[50]; char input1[50]; char yesno; long int size=sizeof(cell); clrscr(); textcolor(YELLOW); makeBox(20,40,40,5); makeBox(32,4,20,2); makeBox(6,10,69,8); makeBox(6,24,69,8); textcolor(DARKGRAY);
INTRODUCTION TO C (CPG102)
Page
91
makeBox(2,2,77,47);
textcolor(WHITE); gotoxy(34,5); cprintf("Update Cellphones"); gotoxy(10,12); cprintf("Company: "); gotoxy(10,16); cprintf("Model: "); gotoxy(10,26); cprintf("Price: "); gotoxy(10,30); cprintf("Quantity: "); textcolor(YELLOW); gotoxy(25,34); cprintf("Update"); gotoxy(48,34); cprintf("Cancel"); textcolor(WHITE); gotoxy(20,39); cprintf("Info"); gotoxy(23,41); textcolor(YELLOW); cprintf("Press ENTER to Update/ C to Cancel"); gotoxy(34,12);
gotoxy(34,16);
INTRODUCTION TO C (CPG102)
Page
92
scanCompany(input);
scanModel(input1);
_setcursortype(_NOCURSOR);
fp=fopen("Cells.dat","rb+");
if(fp==NULL) // if the file couldn't be opened { textcolor(YELLOW); gotoxy(16,42); cprintf("File not found!"); getch(); menu(); } while(fread(&cell,size,1,fp)!=0) //fread returning zero means, the file has reached the end {
&&
break;
INTRODUCTION TO C (CPG102)
Page
93
if(flag==0) // if the record was not found { gotoxy(24,42); textcolor(YELLOW); cprintf("Record not found!"); getch(); menu(); }
gotoxy(34,26);
INTRODUCTION TO C (CPG102)
Page
94
_setcursortype(_SOLIDCURSOR);
} else { menu(); }
fclose(fp);
textcolor(GREEN);
INTRODUCTION TO C (CPG102)
Page
95
gotoxy(25,43);
getch(); menu(); }
//###########################DELETE CELLPHONES############################// void deleteCells() { FILE *fp,*ft; int y=12; int flag=0; char input[50]; char input1[50]; char add; char yesno; long int size; size=sizeof(cell); clrscr();
INTRODUCTION TO C (CPG102)
Page
makeBox(20,40,40,5);
96
textcolor(YELLOW);
textcolor(WHITE); gotoxy(34,5); cprintf("Delete Cellphones"); gotoxy(10,20); cprintf("Company: "); gotoxy(10,24); cprintf("Model: "); textcolor(YELLOW); gotoxy(25,34); cprintf("Delete"); gotoxy(48,34); cprintf("Cancel"); textcolor(WHITE); gotoxy(20,39); cprintf("Info"); textcolor(YELLOW);
INTRODUCTION TO C (CPG102)
Page
97
gotoxy(23,41);
gotoxy(34,5); textcolor(WHITE);
gotoxy(20,39);
INTRODUCTION TO C (CPG102)
Page
98
cprintf("Delete Screen");
textcolor(WHITE); cprintf("Info");
textcolor(YELLOW);
gotoxy(50,9); cprintf("Model");
if(fp==NULL) //if anycase the file cannot be opened { gotoxy(16,42); textcolor(RED); cprintf("File not found!"); getch(); menu(); exit(0);
INTRODUCTION TO C (CPG102)
Page
99
gotoxy(25,y); cprintf("%s",cell.cellCompany);
gotoxy(50,y); cprintf("%s",cell.cellModel);
y++; //print every new records in the new line break; } } if(flag==0) //if the record was not found { //show error message gotoxy(27,43); textcolor(YELLOW); cprintf("Record not found!");
INTRODUCTION TO C (CPG102)
Page
100
getch(); menu(); } gotoxy(27,42); textcolor(YELLOW); cprintf("Delete the record? (y/n)"); fflush(stdin); yesno=getche(); if(yesno=='y' || yesno=='Y') { ft=fopen("temp.dat","wb+"); //creates a new temp.dat file
//to copy every record from original to temp except the record to be deleted. while(fread(&cell,size,1,fp)!=0) { if(stricmp(cell.cellModel,input1)!=0) { fwrite(&cell,size,1,ft); //write every record into temp.dat } } fclose(fp); fclose(ft);
INTRODUCTION TO C (CPG102)
Page
101
INTRODUCTION TO C (CPG102)
Page
102
//##########################MANAGE ACCESSORIES##############################//
void manageAccessories() { char insChoice; do { clrscr(); textcolor(DARKGRAY); makeBox(2,2,77,47); textcolor(YELLOW); makeBox(20,40,40,5); makeBox(32,4,21,2); makeBox(6,10,69,20); textcolor(WHITE); gotoxy(34,5); cprintf("Manage Accessories"); textcolor(WHITE); textcolor(WHITE); gotoxy(10,12); cprintf("1. Add Accessories"); gotoxy(10,16); cprintf("2. List/Search Accessories");
INTRODUCTION TO C (CPG102)
Page
103
gotoxy(10,20); cprintf("3. Update Accessories"); gotoxy(10,24); cprintf("4. Delete Accessories"); gotoxy(10,28); cprintf("5. Menu"); textcolor(WHITE); gotoxy(20,39); cprintf("Info"); textcolor(WHITE); gotoxy(28,41); cprintf("Press Option(1/2/3/4/5):"); gotoxy(53,41); fflush(stdin); insChoice=getche(); getch();
if(insChoice!='1' && insChoice!='2' && insChoice!='3' && insChoice!='4' && insChoice!='5') { gotoxy(35,43); cprintf("Invalid Option!"); getch(); } }while(insChoice!='1' && insChoice!='2' && insChoice!='3' && insChoice!='4' && insChoice!='5');
INTRODUCTION TO C (CPG102)
Page
104
clrscr(); switch(insChoice) { case '1': { addAccessories(); }break; case '2': { searchListAccessories(); }break; case '3': { updateAccessories(); }break; case '4': { deleteAccessories(); }break; case '5': { menu(); }break; } getch();
INTRODUCTION TO C (CPG102)
Page
105
//#########################ADD ACCESSORIES############################// void addAccessories() { FILE *fp; long int size; char add; char exit; size=sizeof(access);
INTRODUCTION TO C (CPG102)
Page
106
cprintf("Details"); gotoxy(11,16); cprintf("Company:"); gotoxy(11,20); cprintf("Model: "); gotoxy(11,24); cprintf("Price(Rs.): "); gotoxy(11,28); cprintf("Quantity: "); textcolor(YELLOW); gotoxy(20,32); cprintf("Add"); gotoxy(40,32); cprintf("Reset"); gotoxy(60,32); cprintf("Cancel"); textcolor(WHITE); gotoxy(20,39); cprintf("Info"); gotoxy(20,41); textcolor(YELLOW); cprintf("Press ENTER to ADD/ R to RESET/ C to CANCEL"); textcolor(YELLOW);
INTRODUCTION TO C (CPG102)
Page
107
gotoxy(31,16); _setcursortype(_SOLIDCURSOR); fflush(stdin); scanCompany(access.accCompany); gotoxy(31,20); fflush(stdin); scanModel(access.accModel); gotoxy(31,24); fflush(stdin); scanPrice(access.accPrice); gotoxy(31,28); fflush(stdin); scanQuantity(access.accQuantity);
_setcursortype(_NOCURSOR);
add=getch(); if(add=='r' || add=='R')//used to reset the window { addAccessories(); } else if(add=='c' || add=='C')//go back to main menu after cancelling { menu(); }
INTRODUCTION TO C (CPG102)
Page
108
fp=fopen("Accessories.dat","ab+");
if(fp==NULL) // if the file couldn't be opened { textcolor(YELLOW); gotoxy(29,43); cprintf("File not found!"); getch(); menu(); }
gotoxy(22,42); textcolor(YELLOW); cprintf("The accessory was successfully recorded!"); gotoxy(29,43); cprintf("Add another record? (Y/N)");
INTRODUCTION TO C (CPG102)
Page
109
exit=getch(); if(exit=='y' || exit=='Y')//decision for new data input { addAccessories(); } else { menu(); }
//#########################SEARCH/LIST ACCESSORIES####################//
int flag=0; char input[50]; char input1[50]; long int size=sizeof(access); clrscr(); textcolor(YELLOW);
INTRODUCTION TO C (CPG102)
Page
110
textcolor(WHITE); gotoxy(34,5); cprintf("Search/List Accessories"); gotoxy(8,14); cprintf("Company: "); gotoxy(8,18); cprintf("Model: "); textcolor(YELLOW); gotoxy(25,32); cprintf("Search"); gotoxy(48,32); cprintf("Cancel"); gotoxy(20,39); textcolor(WHITE); cprintf("Info"); textcolor(YELLOW); gotoxy(23,41); cprintf("Press ENTER to Search/ C to Cancel");
INTRODUCTION TO C (CPG102)
Page
111
clrscr(); textcolor(DARKGRAY); makeBox(2,2,77,47); textcolor(YELLOW); makeBox(10,7,60,30); makeBox(30,4,18,2); makeBox(20,40,40,5); gotoxy(34,5); textcolor(WHITE); cprintf("Show Search"); gotoxy(20,39); textcolor(WHITE); cprintf("Info"); //statics tile
INTRODUCTION TO C (CPG102)
Page
112
gotoxy(15,9); cprintf("Company");
gotoxy(30,9); cprintf("Model");
gotoxy(45,9); cprintf("Price");
gotoxy(60,9); cprintf("Quantity");
fp=fopen("Accessories.dat","rb+");
if(fp==NULL) // if the file couldn't be opened { textcolor(YELLOW); gotoxy(30,43); cprintf("File not found!"); getch(); menu(); }
while(fread(&access,size,1,fp)!=0) //fread returning zero means, the file has reached the end
INTRODUCTION TO C (CPG102)
Page
113
&&
textcolor(YELLOW);
gotoxy(15,12); cprintf("%s",access.accCompany);
gotoxy(30,12); cprintf("%s",access.accModel);
gotoxy(45,12); cprintf("%s",access.accPrice);
INTRODUCTION TO C (CPG102)
Page
114
fclose(fp);
getch(); menu();
} //############################UPDATE ACCESSORIES##########################//
void updateAccessories() {
INTRODUCTION TO C (CPG102)
Page
115
char input[50]; char input1[50]; char yesno; long int size=sizeof(access); clrscr(); textcolor(YELLOW); makeBox(20,40,40,5); makeBox(32,4,20,2); makeBox(6,10,69,8); makeBox(6,24,69,8); textcolor(DARKGRAY); makeBox(2,2,77,47);
textcolor(WHITE); gotoxy(34,5); cprintf("Update Accessories"); gotoxy(10,12); cprintf("Company: "); gotoxy(10,16); cprintf("Model: "); gotoxy(10,26); cprintf("Price: "); gotoxy(10,30); cprintf("Quantity: "); textcolor(YELLOW);
INTRODUCTION TO C (CPG102)
Page
116
gotoxy(25,34); cprintf("Update"); gotoxy(48,34); cprintf("Cancel"); textcolor(WHITE); gotoxy(20,39); cprintf("Info"); gotoxy(23,41); textcolor(YELLOW); cprintf("Press ENTER to Update/ C to Cancel"); gotoxy(34,12); scanCompany(input); gotoxy(34,16); scanModel(input1);
_setcursortype(_NOCURSOR);
fp=fopen("Accessories.dat","rb+");
if(fp==NULL) // if the file couldn't be opened { textcolor(YELLOW); gotoxy(16,42); cprintf("File not found!"); getch();
INTRODUCTION TO C (CPG102)
Page
117
menu(); } while(fread(&access,size,1,fp)!=0) //fread returning zero means, the file has reached the end {
&&
break; } }
if(flag==0) // if the record was not found { gotoxy(24,42); textcolor(YELLOW); cprintf("Record not found!"); getch(); menu(); }
INTRODUCTION TO C (CPG102)
Page
118
//scanning the values from user _setcursortype(_SOLIDCURSOR); gotoxy(34,26); fflush(stdin); scanPrice(access.accPrice); gotoxy(34,30); fflush(stdin); scanQuantity(access.accQuantity);
INTRODUCTION TO C (CPG102)
Page
119
} else { menu(); }
fclose(fp);
getch(); menu(); }
INTRODUCTION TO C (CPG102)
Page
void deleteAccessories()
120
//###########################DELETE ACCESSORIES############################//
{ FILE *fp,*ft; int y=12; int flag=0; char input[50]; char input1[50]; char add; char yesno; long int size; size=sizeof(access); clrscr(); textcolor(YELLOW); makeBox(20,40,40,5); makeBox(32,4,20,2); makeBox(6,19,69,6); textcolor(DARKGRAY); makeBox(2,2,77,47);
INTRODUCTION TO C (CPG102)
Page
121
gotoxy(10,24); cprintf("Model: "); textcolor(YELLOW); gotoxy(25,34); cprintf("Delete"); gotoxy(48,34); cprintf("Cancel"); textcolor(WHITE); gotoxy(20,39); cprintf("Info"); textcolor(YELLOW); gotoxy(23,41); cprintf("Press ENTER to Delete/ C to Cancel"); _setcursortype(_SOLIDCURSOR); gotoxy(25,20); fflush(stdin); scanCompany(input); gotoxy(25,24); fflush(stdin); scanModel(input1);
INTRODUCTION TO C (CPG102)
Page
122
menu(); }
textcolor(YELLOW);
gotoxy(50,9); cprintf("Model");
INTRODUCTION TO C (CPG102)
Page
123
if(fp==NULL) //if anycase the file cannot be opened { gotoxy(16,42); textcolor(RED); cprintf("File not found!"); getch(); menu(); exit(0);
gotoxy(25,y); cprintf("%s",access.accCompany);
INTRODUCTION TO C (CPG102)
Page
124
gotoxy(50,y); cprintf("%s",access.accModel);
y++; //print every new records in the new line break; } } if(flag==0) //if the record was not found { //show error message gotoxy(27,43); textcolor(YELLOW); cprintf("Record not found!"); getch(); menu(); } gotoxy(27,42); textcolor(YELLOW); cprintf("Delete the record? (y/n)"); fflush(stdin); yesno=getche(); if(yesno=='y' || yesno=='Y') { ft=fopen("temp.dat","wb+"); //creates a new temp.dat file
INTRODUCTION TO C (CPG102)
Page
125
//to copy every record from original to temp except the record to be deleted. while(fread(&access,size,1,fp)!=0) { if(stricmp(access.accModel,input1)!=0) { fwrite(&access,size,1,ft); //write every record into temp.dat } } fclose(fp); fclose(ft);
INTRODUCTION TO C (CPG102)
Page
126
//##########################MANAGE PARTS##############################//
void manageParts() { char insChoice; do { clrscr(); textcolor(DARKGRAY); makeBox(2,2,77,47); textcolor(YELLOW); makeBox(20,40,40,5); makeBox(32,4,15,2);
INTRODUCTION TO C (CPG102)
Page
127
makeBox(6,10,69,20); textcolor(WHITE); gotoxy(34,5); cprintf("Manage Parts"); textcolor(WHITE); textcolor(WHITE); gotoxy(10,12); cprintf("1. Add Parts"); gotoxy(10,16); cprintf("2. List/Search Parts"); gotoxy(10,20); cprintf("3. Update Parts"); gotoxy(10,24); cprintf("4. Delete Parts"); gotoxy(10,28); cprintf("5. Menu"); textcolor(WHITE); gotoxy(20,39); cprintf("Info"); textcolor(WHITE); gotoxy(28,41); cprintf("Press Option(1/2/3/4/5):"); gotoxy(53,41); fflush(stdin); insChoice=getche();
INTRODUCTION TO C (CPG102)
Page
128
getch();
if(insChoice!='1' && insChoice!='2' && insChoice!='3' && insChoice!='4' && insChoice!='5') { gotoxy(35,43); cprintf("Invalid Option!"); getch(); } }while(insChoice!='1' && insChoice!='2' && insChoice!='3' && insChoice!='4' && insChoice!='5'); clrscr(); switch(insChoice) { case '1': { addParts(); }break; case '2': { searchListParts(); }break; case '3':
updateParts(); }break;
INTRODUCTION TO C (CPG102)
Page
129
//#########################ADD PARTS############################// void addParts() { FILE *fp; long int size; char add; char exit; size=sizeof(part);
clrscr(); textcolor(YELLOW);
INTRODUCTION TO C (CPG102)
Page
130
textcolor(WHITE); gotoxy(34,5); cprintf("Add Parts"); gotoxy(11,14); cprintf("Details"); gotoxy(11,16); cprintf("Company:"); gotoxy(11,20); cprintf("Model: "); gotoxy(11,24); cprintf("Price(Rs.): "); gotoxy(11,28); cprintf("Quantity: "); textcolor(YELLOW); gotoxy(20,32); cprintf("Add"); gotoxy(40,32); cprintf("Reset"); gotoxy(60,32);
INTRODUCTION TO C (CPG102)
Page
131
cprintf("Cancel"); textcolor(WHITE); gotoxy(20,39); cprintf("Info"); gotoxy(20,41); textcolor(YELLOW); cprintf("Press ENTER to ADD/ R to RESET/ C to CANCEL"); textcolor(YELLOW);
//scanning values from user gotoxy(31,16); _setcursortype(_SOLIDCURSOR); fflush(stdin); scanCompany(part.partCompany); gotoxy(31,20); fflush(stdin); scanModel(part.partModel); gotoxy(31,24); fflush(stdin); scanPrice(part.partPrice); gotoxy(31,28); fflush(stdin); scanQuantity(part.partQuantity);
_setcursortype(_NOCURSOR);
INTRODUCTION TO C (CPG102)
Page
132
add=getch(); if(add=='r' || add=='R')//used to reset the window { addParts(); } else if(add=='c' || add=='C')//go back to main menu after cancelling { menu(); }
fp=fopen("Parts.dat","ab+");
if(fp==NULL) // if the file couldn't be opened { textcolor(YELLOW); gotoxy(29,43); cprintf("File not found!"); getch(); menu(); }
else {
INTRODUCTION TO C (CPG102)
Page
133
fwrite(&part,size,1,fp); fclose(fp); }
gotoxy(22,42); textcolor(YELLOW); cprintf("The part was successfully recorded!"); gotoxy(29,43); cprintf("Add another record? (Y/N)"); exit=getch(); if(exit=='y' || exit=='Y')//decision for new data input { addParts(); } else { menu(); }
//#########################SEARCH/LIST PARTS####################//
void searchListParts()
INTRODUCTION TO C (CPG102)
Page
134
int flag=0; char input[50]; char input1[50]; long int size=sizeof(part); clrscr(); textcolor(YELLOW); makeBox(20,40,40,5); makeBox(32,4,20,2); makeBox(6,12,69,8); textcolor(DARKGRAY); makeBox(2,2,77,47);
textcolor(WHITE); gotoxy(34,5); cprintf("Search/List Parts"); gotoxy(8,14); cprintf("Company: "); gotoxy(8,18); cprintf("Model: "); textcolor(YELLOW); gotoxy(25,32);
INTRODUCTION TO C (CPG102)
Page
135
cprintf("Search"); gotoxy(48,32); cprintf("Cancel"); gotoxy(20,39); textcolor(WHITE); cprintf("Info"); textcolor(YELLOW); gotoxy(23,41); cprintf("Press ENTER to Search/ C to Cancel");
INTRODUCTION TO C (CPG102)
Page
136
makeBox(10,7,60,30); makeBox(30,4,18,2); makeBox(20,40,40,5); gotoxy(34,5); textcolor(WHITE); cprintf("Show Search"); gotoxy(20,39); textcolor(WHITE); cprintf("Info"); //statics tile gotoxy(15,9); cprintf("Company");
gotoxy(30,9); cprintf("Model");
gotoxy(45,9); cprintf("Price");
gotoxy(60,9); cprintf("Quantity");
fp=fopen("Parts.dat","rb+");
INTRODUCTION TO C (CPG102)
Page
137
while(fread(&part,size,1,fp)!=0) //fread returning zero means, the file has reached the end {
&&
textcolor(YELLOW);
gotoxy(15,12); cprintf("%s",part.partCompany);
gotoxy(30,12); cprintf("%s",part.partModel);
INTRODUCTION TO C (CPG102)
Page
gotoxy(45,12);
138
cprintf("%s",part.partPrice);
if(flag==0) // if the record was not found { gotoxy(30,43); textcolor(YELLOW); cprintf("Record not found!"); }
fclose(fp);
getch(); menu();
INTRODUCTION TO C (CPG102)
Page
139
} //############################UPDATE PARTS##########################//
void updateParts() {
FILE *fp; int flag=0; char input[50]; char input1[50]; char yesno; long int size=sizeof(part); clrscr(); textcolor(YELLOW); makeBox(20,40,40,5); makeBox(32,4,15,2); makeBox(6,10,69,8); makeBox(6,24,69,8); textcolor(DARKGRAY); makeBox(2,2,77,47);
INTRODUCTION TO C (CPG102)
Page
140
cprintf("Company: "); gotoxy(10,16); cprintf("Model: "); gotoxy(10,26); cprintf("Price: "); gotoxy(10,30); cprintf("Quantity: "); textcolor(YELLOW); gotoxy(25,34); cprintf("Update"); gotoxy(48,34); cprintf("Cancel"); textcolor(WHITE); gotoxy(20,39); cprintf("Info"); gotoxy(23,41); textcolor(YELLOW); cprintf("Press ENTER to Update/ C to Cancel"); gotoxy(34,12); scanCompany(input); gotoxy(34,16); scanModel(input1);
_setcursortype(_NOCURSOR);
INTRODUCTION TO C (CPG102)
Page
141
fp=fopen("Parts.dat","rb+");
if(fp==NULL) // if the file couldn't be opened { textcolor(YELLOW); gotoxy(16,42); cprintf("File not found!"); getch(); menu(); } while(fread(&part,size,1,fp)!=0) //fread returning zero means, the file has reached the end {
&&
break; } }
INTRODUCTION TO C (CPG102)
Page
142
//scanning the values from user _setcursortype(_SOLIDCURSOR); gotoxy(34,26); fflush(stdin); scanPrice(part.partPrice); gotoxy(34,30); fflush(stdin);
INTRODUCTION TO C (CPG102)
Page
143
scanQuantity(part.partQuantity);
} else { menu(); }
fclose(fp);
INTRODUCTION TO C (CPG102)
Page
144
getch(); menu(); }
//###########################DELETE PARTS############################// void deleteParts() { FILE *fp,*ft; int y=12; int flag=0; char input[50]; char input1[50]; char add; char yesno; long int size; size=sizeof(part); clrscr(); textcolor(YELLOW); makeBox(20,40,40,5); makeBox(32,4,15,2); makeBox(6,19,69,6); textcolor(DARKGRAY); makeBox(2,2,77,47);
INTRODUCTION TO C (CPG102)
Page
145
textcolor(WHITE); gotoxy(34,5); cprintf("Delete Parts"); gotoxy(10,20); cprintf("Company: "); gotoxy(10,24); cprintf("Model: "); textcolor(YELLOW); gotoxy(25,34); cprintf("Delete"); gotoxy(48,34); cprintf("Cancel"); textcolor(WHITE); gotoxy(20,39); cprintf("Info"); textcolor(YELLOW); gotoxy(23,41); cprintf("Press ENTER to Delete/ C to Cancel"); _setcursortype(_SOLIDCURSOR); gotoxy(25,20); fflush(stdin); scanCompany(input); gotoxy(25,24);
INTRODUCTION TO C (CPG102)
Page
146
fflush(stdin); scanModel(input1);
textcolor(YELLOW);
INTRODUCTION TO C (CPG102)
Page
147
gotoxy(50,9); cprintf("Model");
if(fp==NULL) //if anycase the file cannot be opened { gotoxy(16,42); textcolor(RED); cprintf("File not found!"); getch(); menu(); exit(0);
INTRODUCTION TO C (CPG102)
Page
148
{ flag=1;
gotoxy(25,y); cprintf("%s",part.partCompany);
gotoxy(50,y); cprintf("%s",part.partModel);
y++; //print every new records in the new line break; } } if(flag==0) //if the record was not found { //show error message gotoxy(27,43); textcolor(YELLOW); cprintf("Record not found!"); getch(); menu(); } gotoxy(27,42); textcolor(YELLOW);
INTRODUCTION TO C (CPG102)
Page
149
cprintf("Delete the record? (y/n)"); fflush(stdin); yesno=getche(); if(yesno=='y' || yesno=='Y') { ft=fopen("temp.dat","wb+"); //creates a new temp.dat file
//to copy every record from original to temp except the record to be deleted. while(fread(&part,size,1,fp)!=0) { if(stricmp(part.partModel,input1)!=0) { fwrite(&part,size,1,ft); //write every record into temp.dat } } fclose(fp); fclose(ft);
INTRODUCTION TO C (CPG102)
Page
150
//#########################SCAN COMPANY###############################// void scanCompany(char *Company)//custom scanf function for names { char input[50];
INTRODUCTION TO C (CPG102)
Page
151
char in; int count=0; do { in= getch(); if(in==13 && count>0)//if the user presses enter { break; } else if(in==8 && count>0)//if the user presses backspaces { printf("%c%c%c",8,32,8); count-=2; } else if(in==27)//if user presses escape { splash();
} else if(in!=13 && in!=8 && in!=27 &&(in>=65 && in<=90)) { input[count]=in; cprintf("%c",input[count]); } else
INTRODUCTION TO C (CPG102)
Page
152
{ continue; } count++; }while(count<50); input[count]='\0'; strcpy(Company,input);//copy the value of the input to name }//end of function
//#####################SCAN MODEL##############################//
void scanModel(char *Model)//custom scanf function for names { char input[50]; char in; int count=0; do { in= getch(); if(in==13 && count>0)//if the user presses enter { break; } else if(in==8 && count>0)//if the user presses backspaces {
INTRODUCTION TO C (CPG102)
Page
153
} else if(in!=13 && in!=8 && in!=27 && ((in>=46 && in<=57) || (in>=65 && in<=90)))//validation for modelno { input[count]=in; cprintf("%c",input[count]); } else { continue; } count++; }while(count<50); input[count]='\0'; strcpy(Model,input);//copy the value of the input to model }//end of function
INTRODUCTION TO C (CPG102)
Page
154
//###########################SCAN PRICE##################################//
void scanPrice(char *Price)//custom scanf function for names { char input[50]; char in; int count=0; do { in= getch(); if(in==13 && count>0)//if the user presses enter { break; } else if(in==8 && count>0)//if the user presses backspaces { printf("%c%c%c",8,32,8); count-=2; } else if(in==27)//if user presses escape { splash();
INTRODUCTION TO C (CPG102)
Page
155
else if(in!=13 && in!=8 && in!=27 && (in>=47 && in<=57))//validation for date format { input[count]=in; cprintf("%c",input[count]); } else { continue; } count++; }while(count<50); input[count]='\0'; strcpy(Price,input);//co
//###########################SCAN QUANTITY#################################//
int count=0; do
INTRODUCTION TO C (CPG102)
Page
156
char in;
{ in= getch(); if(in==13 && count>0)//if the user presses enter { break; } else if(in==8 && count>0)//if the user presses backspaces { printf("%c%c%c",8,32,8); count-=2; } else if(in==27)//if user presses escape { splash();
} else if(in!=13 && in!=8 && in!=27 && (in>=47 && in<=57))//validation for date format { input[count]=in; cprintf("%c",input[count]); } else { continue;
INTRODUCTION TO C (CPG102)
Page
157
//#########################SCAN USERNAME##########################//
void scanUsername(char *User)//custom scanf function for username { char input[50]; char in; int count=0; do { in= getch(); if(in==13 && count>0)//if the user presses enter { break; } else if(in==8 && count>0)//if the user presses backspaces { printf("%c%c%c",8,32,8);
INTRODUCTION TO C (CPG102)
Page
158
} else if(in!=13 && in!=8 && in!=27 && ((in>=48 && in<=57) || (in>=65 && in<=90) || (in>=97 && in<=122))) { input[count]=in; cprintf("%c",input[count]); } else { continue; } count++; }while(count<50); input[count]='\0'; strcpy(User,input);//copy the value of the input to user }//end of function
INTRODUCTION TO C (CPG102)
Page
//########################SCAN PASSWORD#######################//
159
void scanPassword(char *pass)//custom scanf function for password { char input[50]; char in; int count=0; do { in= getch(); if(in==13 && count>0)//if the user presses enter { break; } else if(in==8 && count>0)//if the user presses backspaces { printf("%c%c%c",8,32,8); count-=2; } else if(in==27)//if user presses escape { splash();
} else if(in!=13 && in!=8 && in!=27 &&((in>=48 && in<=57)|| (in>=65 && in<=90) || (in>=97 && in<=122)))
INTRODUCTION TO C (CPG102)
Page
160
{ input[count]=in; cprintf("*"); } else { continue; } count++; }while(count<50); input[count]='\0'; strcpy(pass,input);//copy the value of the input to pass }
//#############################MAKE BOX#############################//
void makeBox(int x, int y, int width, int height) { int i,j; //top left corner gotoxy(x,y); cprintf("%c",218);
INTRODUCTION TO C (CPG102)
Page
161
gotoxy(i,y); cprintf("%c",196);
for(j=y+1;j<y+height;j++)
INTRODUCTION TO C (CPG102)
Page
162
INTRODUCTION TO C (CPG102)
Page
163
Description
Test if the authentication screen appears when a key is pressed in the start-up splash screen.
2.
Test if the authentication is denied when username and password entered is incorrect.
3. 4.
Test if the Main Menu appears when the username and password are accepted. Test if the Manage Laptops screen appears when option 1 is entered in the Main Menu.
5.
Test if the Add Laptops screen appears when option 1 is entered in the Manage Laptops Screen and if the details entered are recorded.
6.
Test if the Search/List Laptops screen appears when option 2 is entered in the Manage Laptops screen and the laptop details entered are listed in Show Search screen.
7.
Test if the Update Laptops screen appears when option 3 is entered in the Manage Laptops screen and if the details entered are updated by searching again.
8.
Test if the Delete Laptops screen appears when option 4 is entered in the Manage Laptops screen and if the details entered are listed in Delete Screen for delete confirmation.
9. 10.
Test to confirm that the laptop records are deleted by searching again. Test if the Main Menu appears when option 5 is selected in the Manage Laptops screen.
11.
Test if the Manage Cellphones screen appears when option 2 is entered in the Main Menu.
INTRODUCTION TO C (CPG102)
Page
164
12.
Test if the Add Cellphones screen appears when option 1 is entered in the Manage Cellphones Screen and if the details entered are recorded.
13.
Test if the Search/List Cellphones screen appears when option 2 is entered in the Manage Cellphones screen and the cellphone details entered are listed in Show Search screen.
14.
Test if the Update Cellphones screen appears when option 3 is entered in the Manage Cellphones screen and if the details entered are updated by searching again.
15.
Test if the Delete Cellphones screen appears when option 4 is entered in the Manage Cellphones screen and if the details entered are listed in Delete Screen for delete confirmation.
16. 17.
Test to confirm that the cellphone records are deleted by searching again. Test if the Main Menu appears when option 5 is selected in the Manage Cellphones screen.
18.
Test if the Manage Accessories screen appears when option 3 is entered in the Main Menu.
19.
Test if the Add Accessories screen appears when option 1 is entered in the Manage Accessories Screen and if the details entered are recorded.
20.
Test if the Search/List Accessories screen appears when option 2 is entered in the Manage Accessories screen and the accessory details entered are listed in Show Search screen.
21.
Test if the Update Accessories screen appears when option 3 is entered in the Manage Accessories screen and if the details entered are updated by searching again.
22.
Test if the Delete Accessories screen appears when option 4 is entered in the Manage Accessories screen and if the details entered are listed in Delete Screen for delete confirmation.
23. 24.
Test to confirm that the accessory records are deleted by searching again. Test if the Main Menu appears when option 5 is selected in the Manage Accessories screen.
INTRODUCTION TO C (CPG102)
Page
165
25.
Test if the Manage Parts screen appears when option 4 is entered in the Main Menu.
26.
Test if the Add Parts screen appears when option 1 is entered in the Manage Parts Screen and if the details entered are recorded.
27.
Test if the Search/List Parts screen appears when option 2 is entered in the Manage Parts screen and the part details entered are listed in Show Search screen.
28.
Test if the Update Parts screen appears when option 3 is entered in the Manage Parts screen and if the details entered are updated by searching again.
29.
Test if the Delete Parts screen appears when option 4 is entered in the Manage Parts screen and if the details entered are listed in Delete Screen for delete confirmation.
30. 31.
Test to confirm that the part records are deleted by searching again. Test if the Main Menu appears when option 5 is selected in the Manage Parts screen.
32.
Test if the Authentication screen appears when option 5 is selected in the Main Menu.
33.
Test if the Exit screen when option e is selected in the Main Menu.
INTRODUCTION TO C (CPG102)
Page
166
Test Cases
Test Case 1: Test if the authentication screen appears when a key is pressed in the start-up splash screen. Test Input: Press any key in splash screen. Result Expected: Authentication screen should appear. Result Shown: Authentication screen appears. Conclusion: The result was show as expected.
Test Case 2: Test if the authentication is denied when username and password entered is incorrect. Test Input: Username and password are entered as asd. Result Expected: Authentication must be denied. Result Shown: Authentication is denied. Conclusion: The result was shown as expected.
Test Case 3: Test if the Main Menu appears when the username and password are accepted. Test Input: Username and password are entered as birat. Result Expected: Authentication must be accepted and Main menu should appear. Result Shown: Authentication is accepted and Main menu is shown. Conclusion: The result was shown as expected.
Test Case 4: Test if the Manage Laptops screen appears when option 1 is entered in the Main Menu. Test Input: Option 1 is entered. Result Expected: Manage Laptops screen must appear. Result Shown: Manage Laptops screen appears. Conclusion: The result was shown as expected.
INTRODUCTION TO C (CPG102)
Page
167
Test Case 5: Test if the Add Laptops screen appears when option 1 is entered in the Manage Laptops Screen and if the details entered are recorded. Test Input: Option 1 is entered and details are entered. Result Expected: Add Laptops screen must appear and details must be recorded. Result Shown: Add Laptops screen appears and details are recorded. Conclusion: The result was shown as expected.
Test Case 6: Test if the Search/List Laptops screen appears when option 2 is entered in the Manage Laptops screen and the laptop details entered are listed in Show Search screen. Test Input: Option 2 is entered and details are entered. Result Expected: Search/List Laptops screen must appear and record must be shown in Show Search screen. Result Shown: Search/List Laptops screen appears and records are shown. Conclusion: The result was shown as expected.
Test Case 7: Test if the Update Laptops screen appears when option 3 is entered in the Manage Laptops screen and if the details entered are updated by searching again. Test Input: Option 3 is entered and details are entered. Result Expected: Update Laptops screen must appear and details must be updated. Result Shown: Update Laptops screen appears and details are updated. Conclusion: The result was shown as expected.
Test Case 8: Test if the Delete Laptops screen appears when option 4 is entered in the Manage Laptops screen and if the details entered are listed in Delete Screen for delete confirmation. Test Input: Option 4 is entered and details are entered.
Result Shown: Delete Laptops screen and Delete screen appears. Conclusion: The result was shown as expected.
INTRODUCTION TO C (CPG102)
Page
168
Result Expected: Delete Laptops screen and Delete screen must appear.
Test Case 9: Test to confirm that the laptop records are deleted by searching again. Test Input: Details are entered in Search/List screen. Result Expected: Record not found message should appear. Result Shown: Record not found message appears. Conclusion: The result was shown as expected.
Test Case 10: Test if the Main Menu appears when option 5 is selected in the Manage Laptops screen. Test Input: Option 5 is entered. Result Expected: Main menu should appear. Result Shown: Main menu appears. Conclusion: The result was shown as expected.
Test Case 11: Test if the Manage Cellphones screen appears when option 2 is entered in the Main Menu. Test Input: Option 1 is entered. Result Expected: Manage Cellphones screen must appear. Result Shown: Manage Cellphones screen appears. Conclusion: The result was shown as expected.
Test Case 12: Test if the Add Cellphones screen appears when option 1 is entered in the Manage Cellphones Screen and if the details entered are recorded. Test Input: Option 1 is entered and details are entered. Result Expected: Add Cellphones screen must appear and details must be recorded. Result Shown: Add Cellphones screen appears and details are recorded.
INTRODUCTION TO C (CPG102)
Page
169
Test Case 13: Test if the Search/List Cellphones screen appears when option 2 is entered in the Manage Cellphones screen and the cellphone details entered are listed in Show Search screen. Test Input: Option 2 is entered and details are entered. Result Expected: Search/List Cellphones screen must appear and record must be shown in Show Search screen. Result Shown: Search/List Cellphones screen appears and records are shown. Conclusion: The result was shown as expected.
Test Case 14: Test if the Update Cellphones screen appears when option 3 is entered in the Manage Cellphones screen and if the details entered are updated by searching again. Test Input: Option 3 is entered and details are entered. Result Expected: Update Cellphones screen must appear and details must be updated. Result Shown: Update Cellphones screen appears and details are updated. Conclusion: The result was shown as expected.
Test Case 15: Test if the Delete Cellphones screen appears when option 4 is entered in the Manage Cellphones screen and if the details entered are listed in Delete Screen for delete confirmation. Test Input: Option 4 is entered and details are entered. Result Expected: Delete Cellphones screen and Delete screen must appear. Result Shown: Delete Cellphones screen and Delete screen appears. Conclusion: The result was show as expected.
Test Case 16: Test to confirm that the cellphone records are deleted by searching again. Test Input: Details are entered in Search/List screen.
Result Shown: Record not found message appears. Conclusion: The result was shown as expected.
INTRODUCTION TO C (CPG102)
Page
170
Test Case 17: Test if the Main Menu appears when option 5 is selected in the Manage Cellphones screen. Test Input: Option 5 is entered. Result Expected: Main menu should appear. Result Shown: Main menu appears. Conclusion: The result was shown as expected.
Test Case 18: Test if the Manage Accessories screen appears when option 3 is entered in the Main Menu. Test Input: Option 1 is entered. Result Expected: Manage Accessories screen must appear. Result Shown: Manage Accessories screen appears Conclusion: The result was shown as expected.
Test Case 19: Test if the Add Accessories screen appears when option 1 is entered in the Manage Accessories Screen and if the details entered are recorded. Test Input: Option 1 is entered and details are entered. Result Expected: Add Accessories screen must appear and details must be recorded. Result Shown: Add Accessories screen appears and details are recorded. Conclusion: The result was shown as expected.
Test Case 20: Test if the Search/List Accessories screen appears when option 2 is entered in the Manage Accessories screen and the accessory details entered are listed in Show Search screen. Test Input: Option 2 is entered and details are entered. Result Expected: Search/List Accessories screen must appear and record must be shown in
Result Shown: Search/List Accessories screen appears and records are shown. Conclusion: The result was shown as expected.
INTRODUCTION TO C (CPG102)
Page
171
Test Case 21: Test if the Update Accessories screen appears when option 3 is entered in the Manage Accessories screen and if the details entered are updated by searching again. Test Input: Option 3 is entered and details are entered. Result Expected: Update Accessories screen must appear and details must be updated. Result Shown: Update Accessories screen appears and details are updated. Conclusion: The result was shown as expected.
Test Case 22: Test if the Delete Accessories screen appears when option 4 is entered in the Manage Accessories screen and if the details entered are listed in Delete Screen for delete confirmation. Test Input: Option 4 is entered and details are entered. Result Expected: Delete Accessories screen and Delete screen must appear. Result Shown: Delete Accessories screen and Delete screen appears. Conclusion: The result was shown as expected.
Test Case 23: Test to confirm that the accessory records are deleted by searching again. Test Input: Details are entered in Search/List screen. Result Expected: Record not found message should appear. Result Shown: Record not found message appears. Conclusion: The result was shown as expected.
Test Case 24: Test if the Main Menu appears when option 5 is selected in the Manage Accessories screen. Test Input: Option 5 is entered. Result Expected: Main menu should appear.
INTRODUCTION TO C (CPG102)
Page
172
Test Case 25: Test if the Manage Parts screen appears when option 4 is entered in the Main Menu. Test Input: Option 1 is entered. Result Expected: Manage Parts screen must appear. Result Shown: Manage Parts screen appears. Conclusion: The result was shown as expected.
Test Case 26: Test if the Add Parts screen appears when option 1 is entered in the Manage Parts Screen and if the details entered are recorded. Test Input: Option 1 is entered and details are entered. Result Expected: Add Parts screen must appear and details must be recorded. Result Shown: Add Parts screen appears and details are recorded. Conclusion: The result was shown as expected.
Test Case 27: Test if the Search/List Parts screen appears when option 2 is entered in the Manage Parts screen and the part details entered are listed in Show Search screen. Test Input: Option 2 is entered and details are entered. Result Expected: Search/List Parts screen must appear and record must be shown in Show Search screen. Result Shown: Search/List Parts screen appears and records are shown. Conclusion: The result was shown as expected.
Test Case 28: Test if the Update Parts screen appears when option 3 is entered in the Manage Parts screen and if the details entered are updated by searching again. Test Input: Option 3 is entered and details are entered.
Result Shown: Update Parts screen appears and details are updated. Conclusion: The result was shown as expected.
INTRODUCTION TO C (CPG102)
Page
173
Result Expected: Update Parts screen must appear and details must be updated.
Test Case 29: Test if the Delete Parts screen appears when option 4 is entered in the Manage Parts screen and if the details entered are listed in Delete Screen for delete confirmation. Test Input: Option 4 is entered and details are entered. Result Expected: Delete Parts screen and Delete screen must appear. Result Shown: Delete Parts screen and Delete screen appears. Conclusion: The result was shown as expected.
Test Case 30: Test to confirm that the part records are deleted by searching again. Test Input: Details are entered in Search/List screen. Result Expected: Record not found message should appear. Result Shown: Record not found message appears. Conclusion: The result was shown as expected.
Test Case 31: Test if the Main Menu appears when option 5 is selected in the Manage Parts screen. Test Input: Option 5 is entered. Result Expected: Main menu should appear. Result Shown: Main menu appears. Conclusion: The result was shown as expected.
Test Case 32: Test if the Authentication screen appears when option 5 is selected in the Main Menu. Test Input: Option 5 is entered. Result Expected: Authentication screen must appear. Result Shown: Authentication screen appears.
INTRODUCTION TO C (CPG102)
Page
174
Test Case 33: Test if the Exit screen when option e is selected in the Main Menu. Test Input: Option e is entered. Result Expected: Exit screen must appear. Result Shown: Exit screen appears. Conclusion: The result was show as expected.
INTRODUCTION TO C (CPG102)
Page
175
Test Log
Test Case No: 1. Test if the authentication screen appears when a key is pressed in the start-up splash screen. 2. Test if the authentication is denied when username and password entered is incorrect. 3. Test if the Main Menu appears when the username and password are accepted. 4. Test if the Manage Laptops screen appears when option 1 is entered in the Main Menu. 5. Test if the Add Laptops screen appears when option 1 is entered in the Manage Laptops Screen and if the details entered are recorded. 6. Test if the Search/List Laptops screen appears when option 2 is entered in Done the Manage Laptops screen and the laptop details entered are listed in Show Search screen. 7. Test if the Update Laptops screen appears when option 3 is entered in the Manage Laptops screen and if the details entered are updated by searching again. 8. Test if the Delete Laptops screen appears when option 4 is entered in the Manage Laptops screen and if the details entered are listed in Delete Screen for delete confirmation. 9. 10. Test to confirm that the laptop records are deleted by searching again. Test if the Main Menu appears when option 5 is selected in the Manage Laptops screen. 11. Test if the Manage Cellphones screen appears when option 2 is entered in Done the Main Menu. Done Done Done Done Done Done Done Done Done Description Outcome
INTRODUCTION TO C (CPG102)
Page
176
12.
Test if the Add Cellphones screen appears when option 1 is entered in the Manage Cellphones Screen and if the details entered are recorded.
Done
13.
Test if the Search/List Cellphones screen appears when option 2 is entered in the Manage Cellphones screen and the cellphone details entered are listed in Show Search screen.
Done
14.
Test if the Update Cellphones screen appears when option 3 is entered in the Manage Cellphones screen and if the details entered are updated by searching again.
Done
15.
Test if the Delete Cellphones screen appears when option 4 is entered in the Manage Cellphones screen and if the details entered are listed in Delete Screen for delete confirmation.
Done
16. 17.
Test to confirm that the cellphone records are deleted by searching again. Test if the Main Menu appears when option 5 is selected in the Manage Cellphones screen.
Done Done
18.
Test if the Manage Accessories screen appears when option 3 is entered in the Main Menu.
Done
19.
Test if the Add Accessories screen appears when option 1 is entered in the Manage Accessories Screen and if the details entered are recorded.
Done
20.
Test if the Search/List Accessories screen appears when option 2 is entered in the Manage Accessories screen and the accessory details entered are listed in Show Search screen.
Done
21.
Test if the Update Accessories screen appears when option 3 is entered in the Manage Accessories screen and if the details entered are updated by searching again.
Done
22.
Test if the Delete Accessories screen appears when option 4 is entered in the Manage Accessories screen and if the details entered are listed in Delete Screen for delete confirmation.
Done
23. 24.
Test to confirm that the accessory records are deleted by searching again. Test if the Main Menu appears when option 5 is selected in the Manage Accessories screen.
Done Done
INTRODUCTION TO C (CPG102)
Page
177
25.
Test if the Manage Parts screen appears when option 4 is entered in the Main Menu.
Done
26.
Test if the Add Parts screen appears when option 1 is entered in the Manage Parts Screen and if the details entered are recorded.
Done
27.
Test if the Search/List Parts screen appears when option 2 is entered in the Manage Parts screen and the part details entered are listed in Show Search screen.
Done
28.
Test if the Update Parts screen appears when option 3 is entered in the Manage Parts screen and if the details entered are updated by searching again.
Done
29.
Test if the Delete Parts screen appears when option 4 is entered in the Manage Parts screen and if the details entered are listed in Delete Screen for delete confirmation.
Done
30. 31.
Test to confirm that the part records are deleted by searching again. Test if the Main Menu appears when option 5 is selected in the Manage Parts screen.
Done Done
32.
Test if the Authentication screen appears when option 5 is selected in the Main Menu.
Done
33.
Test if the Exit screen when option e is selected in the Main Menu.
Done
INTRODUCTION TO C (CPG102)
Page
178
Processor: Pentium III or higher Ram: 64 mb or higher Hard disk: 100 mb free space Floppy disk/CD-ROM/USB drive
Software
Operating System: Windows 98 or later (32-bit) Program: Turbo-C Command window must be changed to following properties: Screen Buffer Size: Width-80 and Height-60 Window Size: Width-80 and Height-60
INTRODUCTION TO C (CPG102)
Page
179
INTRODUCTION TO C (CPG102)
Page
180
2. Username and Password for authentication are birat and birat respectively. They must be entered with correct cases (Uppercase or Lowercase) to go to main menu.
Incorrect username or password is denied for authentication. And only 3 attempts are provided.
INTRODUCTION TO C (CPG102)
Page
181
3. Choose an option and enter the correct option no. to go through the sub-menu. For example, to manage laptops, enter option no. 1.
INTRODUCTION TO C (CPG102)
Page
182
4. After an option is selected in the main menu, the sub-menu for managing products appears. For example, if option 1 is selected, Manage Laptops screen will appear, if option 2 is selected, Manage Cellphones screen will appear and so on.
INTRODUCTION TO C (CPG102)
Page
183
4. Choose an option to manage the products in the Manage screen and enter the correct option to go to sub-menu. For example, to Add laptops, option no. 1 must be entered, to List/search laptops, option no. 2 must be entered and so on.
INTRODUCTION TO C (CPG102)
Page
184
5. In the Add screen, enter the details required for the record. If the details entered are correct, press Enter to record the details, R to reset the details to enter the details again and C to cancel the record. After a product is recorded, press y to add another record or N to go to the main menu.
INTRODUCTION TO C (CPG102)
Page
185
6. In the Search/list screen, enter the company and model details of the product required for searching and listing. If the details entered are correct, press Enter to search and if details are incorrect, press C to cancel and go to main menu.
INTRODUCTION TO C (CPG102)
Page
186
7. If the details are correct, the show search screen will appear that shows the list of searched products. Otherwise, No record found message will appear.
INTRODUCTION TO C (CPG102)
Page
187
8. In the Update screen, enter the details of the product to be updated. If the details are found in the record, confirmation for update will be asked. To update the record, press Y or press N to cancel the update. After confirming the update, enter new details to update the record and press Enter. If the record is updated, record updated successfully message will appear. Then, press any key to go to main menu.
INTRODUCTION TO C (CPG102)
Page
188
9. To show the updated record, go to the search screen and enter the record details. The record will be shown in Show Search screen.
INTRODUCTION TO C (CPG102)
Page
189
10. In the Delete screen, enter the details of the record to be deleted and press Enter to delete or C to cancel the delete and go to main menu.
INTRODUCTION TO C (CPG102)
Page
190
11. If the details of the record to be deleted are correct, the record will be shown in the Delete sub-screen. To confirm the delete, press Y or to cancel and go to main menu, press N. If the record is deleted, Record deleted successfully message will appear and if not deleted, File not found message appears.
INTRODUCTION TO C (CPG102)
Page
191
INTRODUCTION TO C (CPG102)
Page
192
13. In the main menu, press 5 to log out and go to Authentication screen.
INTRODUCTION TO C (CPG102)
Page
193
14. In the main menu, press e to exit from the system. The exit screen will appear with message See you soon where any key can be pressed to exit.
INTRODUCTION TO C (CPG102)
Page
194
CONCLUSION
After the development of the software, following conclusions of its strengths, weaknesses and enhancements were found out from its features:
Strengths
1. Different types of product records can be stored such as Laptops, Cellphones, Accessories and Parts, with details like Company, Model, Price and Quantity. 2. Adding, searching, updating and deleting of records can be easily and efficiently done. 3. Authentication keeps the records safe from loss or theft.
Weaknesses
1. Only one record can be searched and listed at a time. 2. Reset or Cancel cannot function until all the details are entered in the required fields. 3. Option entered in menu cannot be cleared back to enter another option.
Enhancements
1. Search/list feature can be improved for listing more than one product at a time. 2. An addition to print bills and reports can be enhanced.
ACKNOWLEDGEMENT
I, Birat Lal Shrestha, student of Informatics College, am very grateful to the teacher, Sir Prakash Shrestha, for offering me such a great project. He provided us such a huge knowledge that helped to develop this Stock Management System and also helped a lot to clear the confusions and mistakes while doing this project. I am sure that all the knowledge I gained, from him and this work, will be very helpful in our future.
INTRODUCTION TO C (CPG102)
Page
195