CPG102 Birat Lal Shrestha 1801T3100045

195
BIRAT LAL SHRESTHA (1801T3100045)  INTRODUCTION TO C (CPG102)     P    a    g    e     1  STOCK MANAGEMENT SYSTEM  NEOTERIC NEPAL Student Name: Birat Lal Shrestha Student ID: 1801T3100045 Centre Code: 1801 Class Code: IDITC Module Name: Introduction to C (CPG102)

Transcript of CPG102 Birat Lal Shrestha 1801T3100045

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 1/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1

STOCK 

MANAGEMENTSYSTEM

 NEOTERIC NEPAL

Student Name: Birat Lal Shrestha

Student ID: 1801T3100045

Centre Code: 1801

Class Code: IDITC

Module Name: Introduction to C (CPG102)

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 2/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   2

TABLE OF CONTENTS

Chapter PAGE

INTRODUCTION 2-4

REQUIREMENTS SPECIFICATION 5

PROGRAM SPECIFICATION 6

SCREEN DESIGNS 7-18

PROCESSING AND VALIDATION 19

PROGRAM DESIGN 20-163

TESTING 169-178

IMPLEMENTATION 179-194

CONCLUSION 195

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 3/195

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 4/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   4

Current System

The study of the company¶s 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.

4) The current system is less secure as no authentication system is used.

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 5/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   5

REQUIREMENTS SPECIFICATION

Requirements of new system

To avoid the problems specified, the new system needs to include the following requirements:

1) The new system must include and handle all the tasks inside single software.

2) It should be easy to understand and use for the staffs, with simple language.

3) Same types of products must be shown under their relevant category for easier and faster 

searching and modifying.

4) Authentication system must be included having username and password.

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.

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 6/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   6

PROGRAM SPECIFICATION

Input Specification

File Specification

S.

No.

Input

Variable

Description Size(bytes) Data

Type

1. Company It denotes the name of product¶s company. 50 String

2. Model It denotes the model no. of the product. 50 String

3. Price It indicates the price of the product. 50 String

4. Quantity It indicates the quantity or number of the product. 50 String

S.

No.

File

Pointer

Name

Description File name File

Type

1. fp It holds the laptop details to be recorded. Laptops.dat Dat

2. fp It holds the cellphone details to be recorded. Cells.dat Dat

3. fp It holds the accessories details to be recorded. Accessories.dat Dat

4. fp It holds the accessories details to be recorded. Parts.dat Dat

5. ft It holds the temporary details entered. temp.dat Dat

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 7/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   7

SCREEN DESIGNS

Outline Screen Designs

Fig: Start-up Splash

Info

Stock Management System

 Neoteric Nepal

Details

Student ID:

 Name:

Submitted To:

Course Name:

Module Name:

Term:

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 8/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   8Fig: Authentication Screen

AUTHENTICATION REQUIRED

Info

Username:

Password:

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 9/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   9

Fig: Main Menu

Info

Main Menu

1. Manage Laptops

2. Manage Cellphones

3. Manage Accessories

4. Manage Parts

5. Log Out

e. Exit

Press Option(1/2/3/4/5/e):

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 10/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   0

Fig: Manage Parts Menu

Manage Parts

Press Option(1/2/3/4/5):

1. Add Parts

2. Search/List Parts

3. Update Parts

4. Delete Parts

5. Menu

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 11/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   1Fig: Add Screen

Details

ADD RESET CANCEL

Info

Add Record

Press ENTER to ADD/ R to RESET/ C to CANCEL

Company:

Model:

Price(Rs.):

Quantiy:

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 12/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   2

Fig: Search/List Screen

SEARCH CANCEL

Info

Search/List Record

Press ENTER to SEARCH/ C to CANCEL

Company:

Model:

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 13/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   3

Fig: Update Screen

Update Cancel

Info

Update Record

Press ENTER to UPDATE/ C to CANCEL

Company:

Model:

Price:

Quantity:

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 14/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   4Fig: Delete Screen

DELETE CANCEL

Info

Delete Record

Press ENTER to DELETE/ C to CANCEL

Company:

Model:

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 15/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   5

Output Screenshots

Splash Screen

Authentication Screen

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 16/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   6

Main Menu

Manage Screen

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 17/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   7

Add Screen

Search/List Screen

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 18/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   8

Update Screen

Delete Screen

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 19/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   9

PROCESSING AND VALIDATION

Processing 

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 shouldn¶t be used in authentication.

6)  Only dot (.) can be used to enter product price.

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 20/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   2   0

PROGRAM DESIGN

PSUEDOCODE

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 ³CPG102 (INTRODUCTION TO C)´

DISPLAY ³IDITC´

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 21/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   2   1

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!´

DISPLAY ³ATTEMPTS LEFT: ´

END DO

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 22/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   2   2

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

MODULE CUSTOM SCANF FOR PASSWORD

DO

count EQUALS TO 0

DO

DO

GET in

IF in EQUALS TO 13 AND count LESS THAN 0

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 23/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   2   3

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

INCREASE count BY 1

UNTILL count LESS THAN 50

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 24/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   2   4

input[count] EQUALS TO 0

STRING COPY input

END DO

MODULE CUSTOM SCANF FOR USERNAME

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

DO

CALL splash

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 25/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   2   5

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 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

MODULE MENU

DO

DO

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 26/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   2   6

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

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 27/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   2   7

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

END CASE

END DO

MODULE MANAGELAPS 

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 28/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   2   8

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

END DO

choice µ2¶

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 29/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   2   9

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

DO

CREATE FILE *fp

DISPLAY ³ADD LAPTOPS´

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 30/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   3   0

DISPLAY ³DETAILS´

DISPLAY ³COMPANY:´

DISPLAY´MODEL:´

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 DO

END IF

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 31/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   3   1

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 IF

END DO

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 32/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   3   2

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

CALL menu

END DO

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 33/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   3   3

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´

DISPLAY ³laptop lapQuantity´

INCREASE y BY 1

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 34/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   3   4

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

DO

y EQUALS TO 7

flag EQUALS TO 1

CREATE FILE *fp

DISPLAY ³UPDATE LAPTOPS"

DISPLAY ³COMPANY:´

DISPLAY ³MODEL:´

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 35/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   3   5

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

END IF

END DO

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 36/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   3   6

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!´

DISPLAY "PRESS ANY KEY TO GO TO MENU!´

CALL menu

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 37/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   3   7

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

CALL menu

END DO

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 38/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   3   8

END IF

DISPLAY ³DELETE SCREEN´

DISPLAY ³INFO´

DISPLAY ³COMPANY´

DISPLAY ³MODEL´

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´

DISPLAY ³laptop lapModel´

INCREASE y BY 1

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 39/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   3   9

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

END WHILE

CLOSE fp

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 40/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   4   0

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

SIMILAR PSUEDOCODE FOR REST OF THE PRODUCTS

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 41/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   4   1

PROGRAMMING CODE

#include<stdio.h>

#include<conio.h>

#include<string.h>

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

void deleteAccessories();//prototype declaration for delete accessories screen

void manageParts();//prototype declaration for manage parts screen

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 42/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   4   2

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

{

char cellCompany[50];

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 43/195

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 44/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   4   4

splash();

authentication();

menu();

manageLaps();

addLaps();

searchListLaps();

updateLaps();

deleteLaps();

}

//####################SPLASH SCREEN##########################//

void splash()

{

textbackground(BLACK);

clrscr();

textcolor(DARKGRAY);

makeBox(2,2,77,47);

textcolor(WHITE);

makeBox(19,4,42,4);

makeBox(20,5,40,3);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 45/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   4   5

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: ");

gotoxy(21,25);

cprintf("Course Name: ");

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 46/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   4   6

gotoxy(21,26);

cprintf("Module Name: ");

gotoxy(21,27);

cprintf("Term: ");

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");

textcolor(CYAN);

gotoxy(25,37);

cprintf("Press any key to continue....");

textcolor(BLACK);

 _setcursortype(_NOCURSOR);

getch();

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 47/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   4   7

authentication();

}

//#######################AUTHENTICATION############################//

void authentication()

{

char username[50], password[50];

int i,j;

char input;

for(i=1;i<=3;i++)

{

textbackground(BLACK);

clrscr();

textcolor(DARKGRAY);

makeBox(2,2,77,47);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 48/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   4   8

textcolor(YELLOW);

makeBox(27,20,25,4);

makeBox(20,36,40,5);

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");

 _setcursortype(_SOLIDCURSOR);

textcolor(WHITE);

gotoxy(38,21);

fflush(stdin);

//scanf("%s",username);

scanUsername(username);

gotoxy(38,23);

fflush(stdin);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 49/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   4   9

//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();

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 50/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   5   0

//clrscr();

}

else

{

clrscr();

gotoxy(18,10);

textcolor(GREEN);

cprintf("No authentication attempt left. Try next time!");

getch();

exit(0);

}

getch();

}

//#########################MENU###################################//

void menu()

{

char choice;

do

{

clrscr();

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 51/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   5   1

textcolor(DARKGRAY);

makeBox(2,2,77,47);

textcolor(YELLOW);

makeBox(20,40,40,5);

makeBox(32,4,12,2);

makeBox(6,10,69,25);

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");

textcolor(WHITE);

gotoxy(28,41);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 52/195

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 53/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   5   3

}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!");

getch();

exit(0);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 54/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   5   4

}break;

}

getch();

}

//#############################MANAGE

LAPTOPS##########################//

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");

textcolor(WHITE);

textcolor(WHITE);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 55/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   5   5

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();

if(insChoice!='1' && insChoice!='2' && insChoice!='3' && insChoice!='4' &&

insChoice!='5')

{

gotoxy(35,43);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 56/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   5   6

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();

}break;

case '5':

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 57/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   5   7

{

menu();

}break;

}

getch();

}

//#########################ADD LAPTOPS############################//

void addLaps()

{

FILE *fp;

long int size;

char add;

char exit;

size=sizeof(laptop);

clrscr();

textcolor(YELLOW);

makeBox(18,40,46,5);

makeBox(32,4,14,2);

makeBox(6,15,69,15);

textcolor(DARKGRAY);

makeBox(2,2,77,47);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 58/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   5   8

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);

cprintf("Info");

gotoxy(20,41);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 59/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   5   9

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(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);

add=getch();

if(add=='r' || add=='R')//used to reset the window

{

addLaps();

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 60/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   6   0

}

else if(add=='c' || add=='C')//go back to main menu after cancelling

{

menu();

}

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();

}

else

{

fwrite(&laptop,size,1,fp);

fclose(fp);

}

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 61/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   6   1

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####################//

void searchListLaps()

{

FILE *fp;

int y=7;

int flag=0;

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 62/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   6   2

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");

gotoxy(20,39);

textcolor(WHITE);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 63/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   6   3

cprintf("Info");

textcolor(YELLOW);

gotoxy(23,41);

cprintf("Press ENTER to Search/ C to Cancel");

 _setcursortype(_SOLIDCURSOR);

gotoxy(23,14);

scanCompany(input);

gotoxy(23,18);

scanModel(input1);

 _setcursortype(_NOCURSOR);

if(getch()=='c' || getch()=='c')

{

menu();

}

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);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 64/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   6   4

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("Laptops.dat","rb+");

if(fp==NULL) // if the file couldn't be opened

{

textcolor(YELLOW);

gotoxy(30,43);

cprintf("File not found!");

getch();

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 65/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   6   5

menu();

}

while(fread(&laptop,size,1,fp)!=0) //fread returning zero means, the file has reached the

end

{

if((stricmp(input,laptop.lapCompany)==0) &&

(stricmp(input1,laptop.lapModel)==0))

{

flag=1;

textcolor(YELLOW);

gotoxy(15,12);

cprintf("%s",laptop.lapCompany);

gotoxy(30,12);

cprintf("%s",laptop.lapModel);

gotoxy(45,12);

cprintf("%s",laptop.lapPrice);

gotoxy(60,12);

cprintf("%s",laptop.lapQuantity);

y++;

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 66/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   6   6

}

}

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);

cprintf("Press any key to go to menu!");

getch();

menu();

}

//############################UPDATE LAPTOPS##########################//

void updateLaps()

{

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 67/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   6   7

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: ");

gotoxy(10,26);

cprintf("Price: ");

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 68/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   6   8

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+");

if(fp==NULL) // if the file couldn't be opened

{

textcolor(YELLOW);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 69/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   6   9

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

{

if((stricmp(input,laptop.lapCompany)==0) &&

(stricmp(input1,laptop.lapModel)==0))

{

flag=1;

 break;

}

}

if(flag==0) // if the record was not found

{

gotoxy(24,42);

textcolor(YELLOW);

cprintf("Record not found!");

getch();

menu();

}

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 70/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   7   0

//ASK for the confirmation to modify

gotoxy(27,42);

cprintf("Update the record? (y/n)");

fflush(stdin);

yesno=getche();

if(yesno=='y' || yesno=='Y')

{

//modifying steps

//scanning the values from user 

 _setcursortype(_SOLIDCURSOR);

gotoxy(34,26);

fflush(stdin);

scanPrice(laptop.lapPrice);

gotoxy(34,30);

fflush(stdin);

scanQuantity(laptop.lapQuantity);

//seek one record up

fseek(fp,-size,SEEK_CUR);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 71/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   7   1

//write the modified record into the file

fwrite(&laptop,size,1,fp);

}

else

{

menu();

}

fclose(fp);

textcolor(GREEN);

gotoxy(25,43);

cprintf("Record updated successfully!");

textcolor(YELLOW);

gotoxy(25,44);

cprintf("Press any key to go to menu!");

getch();

menu();

}

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 72/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   7   2

//###########################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);

gotoxy(34,5);

cprintf("Delete Laptops");

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 73/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   7   3

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);

 _setcursortype(_NOCURSOR);

add=getch();

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 74/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   7   4

if(add=='c' || add=='c')

{

menu();

}

clrscr();

textcolor(YELLOW);

makeBox(20,40,40,5);

makeBox(31,4,17,2);

makeBox(10,7,60,30);

gotoxy(34,5);

textcolor(WHITE);

cprintf("Delete Screen");

gotoxy(20,39);

textcolor(WHITE);

cprintf("Info");

textcolor(YELLOW);

gotoxy(25,9);//statics tile

cprintf("Company");

gotoxy(50,9);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 75/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   7   5

cprintf("Model");

fp=fopen("Laptops.dat","rb+");//opens Instruments.dat file

if(fp==NULL) //if anycase the file cannot be opened

{

gotoxy(16,42);

textcolor(RED);

cprintf("File not found!");

getch();

menu();

exit(0);

}

while(fread(&laptop,size,1,fp)!=0)//read file

{

if((stricmp(input,laptop.lapCompany)==0) &&

(stricmp(input1,laptop.lapModel)==0))

{

flag=1;

gotoxy(25,y);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 76/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   7   6

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();

if(yesno=='y' || yesno=='Y')

{

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 77/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   7   7

ft=fopen("temp.dat","wb+"); //creates a new temp.dat file

rewind(fp); //rewind the original file InsChart.dat

//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);

//delete the original file

remove("Laptops.dat");

//rename the temp.dat to Instruments.dat

rename("temp.dat","Laptops.dat");

gotoxy(25,43);

textcolor(GREEN);

cprintf("Record deleted successfully!");

getch();

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 78/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   7   8

menu();

}

else

{

gotoxy(27,43);

textcolor(YELLOW);

cprintf("Record not deleted!");

getch();

menu();

}

}

//##########################MANAGE CELLS##############################//

void manageCells()

{

char insChoice;

do

{

clrscr();

textcolor(YELLOW);

makeBox(20,40,40,5);

makeBox(32,4,21,2);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 79/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   7   9

makeBox(6,10,69,20);

textcolor(DARKGRAY);

makeBox(2,2,77,47);

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);

gotoxy(28,41);

cprintf("Press Option(1/2/3/4/5):");

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 80/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   8   0

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');

clrscr();

switch(insChoice)

{

case '1':

{

addCells();

}break;

case '2':

{

searchListCells();

}break;

case '3':

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 81/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   8   1

{

updateCells();

}break;

case '4':

{

deleteCells();

}break;

case '5':

{

menu();

}break;

}

getch();

}

//#########################ADD CELLPHONES############################//

void addCells()

{

FILE *fp;

long int size;

char add;

char exit;

size=sizeof(cell);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 82/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   8   2

clrscr();

textcolor(YELLOW);

makeBox(18,40,46,5);

makeBox(32,4,16,2);

makeBox(6,15,69,15);

textcolor(DARKGRAY);

makeBox(2,2,77,47);

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);

gotoxy(20,32);

cprintf("Add");

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 83/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   8   3

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);

gotoxy(31,28);

fflush(stdin);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 84/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   8   4

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();

}

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 85/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   8   5

else

{

fwrite(&cell,size,1,fp);

fclose(fp);

}

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();

}

}

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 86/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   8   6

//#########################SEARCH/LIST CELLPHONES####################//

void searchListCells()

{

FILE *fp;

int y=7;

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);

textcolor(WHITE);

gotoxy(34,5);

cprintf("Search/List CellPhones");

gotoxy(8,14);

cprintf("Company: ");

gotoxy(8,18);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 87/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   8   7

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");

 _setcursortype(_SOLIDCURSOR);

gotoxy(23,14);

scanCompany(input);

gotoxy(23,18);

scanModel(input1);

 _setcursortype(_NOCURSOR);

if(getch()=='c' || getch()=='c')

{

menu();

}

clrscr();

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 88/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   8   8

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);

cprintf("Quantity");

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 89/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   8   9

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

{

if((stricmp(input,cell.cellCompany)==0) &&

(stricmp(input1,cell.cellModel)==0))

{

flag=1;

textcolor(YELLOW);

gotoxy(15,12);

cprintf("%s",cell.cellCompany);

gotoxy(30,12);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 90/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   9   0

cprintf("%s",cell.cellModel);

gotoxy(45,12);

cprintf("%s",cell.cellPrice);

gotoxy(60,12);

cprintf("%s",cell.cellQuantity);

y++;

}

}

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);

cprintf("Press any key to go to menu!");

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 91/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   9   1

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);

makeBox(2,2,77,47);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 92/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   9   2

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);

scanCompany(input);

gotoxy(34,16);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 93/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   9   3

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

{

if((stricmp(input,cell.cellCompany)==0) &&

(stricmp(input1,cell.cellModel)==0))

{

flag=1;

 break;

}

}

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 94/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   9   4

if(flag==0) // if the record was not found

{

gotoxy(24,42);

textcolor(YELLOW);

cprintf("Record not found!");

getch();

menu();

}

//ASK for the confirmation to modify

gotoxy(27,42);

cprintf("Update the record? (y/n)");

fflush(stdin);

yesno=getche();

if(yesno=='y' || yesno=='Y')

{

//modifying steps

//scanning the values from user 

 _setcursortype(_SOLIDCURSOR);

gotoxy(34,26);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 95/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   9   5

fflush(stdin);

scanPrice(cell.cellPrice);

gotoxy(34,30);

fflush(stdin);

scanQuantity(cell.cellQuantity);

//seek one record up

fseek(fp,-size,SEEK_CUR);

//write the modified record into the file

fwrite(&cell,size,1,fp);

}

else

{

menu();

}

fclose(fp);

textcolor(GREEN);

gotoxy(25,43);

cprintf("Record updated successfully!");

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 96/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   9   6

textcolor(YELLOW);

gotoxy(25,44);

cprintf("Press any key to go to menu!");

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();

textcolor(YELLOW);

makeBox(20,40,40,5);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 97/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   9   7

makeBox(32,4,20,2);

makeBox(6,19,69,6);

textcolor(DARKGRAY);

makeBox(2,2,77,47);

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);

gotoxy(23,41);

cprintf("Press ENTER to Delete/ C to Cancel");

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 98/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   9   8

 _setcursortype(_SOLIDCURSOR);

gotoxy(25,20);

fflush(stdin);

scanCompany(input);

gotoxy(25,24);

fflush(stdin);

scanModel(input1);

 _setcursortype(_NOCURSOR);

add=getch();

if(add=='c' || add=='c')

{

menu();

}

clrscr();

textcolor(YELLOW);

makeBox(20,40,40,5);

makeBox(31,4,17,2);

makeBox(10,7,60,30);

gotoxy(34,5);

textcolor(WHITE);

cprintf("Delete Screen");

gotoxy(20,39);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 99/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   9   9

textcolor(WHITE);

cprintf("Info");

textcolor(YELLOW);

gotoxy(25,9);//statics tile

cprintf("Company");

gotoxy(50,9);

cprintf("Model");

fp=fopen("Cells.dat","rb+");//opens Instruments.dat file

if(fp==NULL) //if anycase the file cannot be opened

{

gotoxy(16,42);

textcolor(RED);

cprintf("File not found!");

getch();

menu();

exit(0);

}

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 100/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   0   0

while(fread(&cell,size,1,fp)!=0)//read file

{

if((stricmp(input,cell.cellCompany)==0) &&

(stricmp(input1,cell.cellModel)==0))

{

flag=1;

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!");

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 101/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   0   1

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

rewind(fp); //rewind the original file InsChart.dat

//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);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 102/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   0   2

//delete the original file

remove("Cells.dat");

//rename the temp.dat to Instruments.dat

rename("temp.dat","Cells.dat");

gotoxy(25,43);

textcolor(GREEN);

cprintf("Record deleted successfully!");

getch();

menu();

}

else

{

gotoxy(27,43);

textcolor(YELLOW);

cprintf("Record not deleted!");

getch();

menu();

}

}

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 103/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   0   3

//##########################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");

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 104/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   0   4

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');

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 105/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   0   5

clrscr();

switch(insChoice)

{

case '1':

{

addAccessories();

}break;

case '2':

{

searchListAccessories();

}break;

case '3':

{

updateAccessories();

}break;

case '4':

{

deleteAccessories();

}break;

case '5':

{

menu();

}break;

}

getch();

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 106/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   0   6

}

//#########################ADD ACCESSORIES############################//

void addAccessories()

{

FILE *fp;

long int size;

char add;

char exit;

size=sizeof(access);

clrscr();

textcolor(YELLOW);

makeBox(18,40,46,5);

makeBox(32,4,18,2);

makeBox(6,15,69,15);

textcolor(DARKGRAY);

makeBox(2,2,77,47);

textcolor(WHITE);

gotoxy(34,5);

cprintf("Add Accessories");

gotoxy(11,14);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 107/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   0   7

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);

//scanning values from user 

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 108/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   0   8

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();

}

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 109/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   0   9

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();

}

else

{

fwrite(&access,size,1,fp);

fclose(fp);

}

gotoxy(22,42);

textcolor(YELLOW);

cprintf("The accessory was successfully recorded!");

gotoxy(29,43);

cprintf("Add another record? (Y/N)");

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 110/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   1   0

exit=getch();

if(exit=='y' || exit=='Y')//decision for new data input

{

addAccessories();

}

else

{

menu();

}

}

//#########################SEARCH/LIST ACCESSORIES####################//

void searchListAccessories()

{

FILE *fp;

int y=7;

int flag=0;

char input[50];

char input1[50];

long int size=sizeof(access);

clrscr();

textcolor(YELLOW);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 111/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   1   1

makeBox(20,40,40,5);

makeBox(32,4,25,2);

makeBox(6,12,69,8);

textcolor(DARKGRAY);

makeBox(2,2,77,47);

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");

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 112/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   1   2

 _setcursortype(_SOLIDCURSOR);

gotoxy(23,14);

scanCompany(input);

gotoxy(23,18);

scanModel(input1);

 _setcursortype(_NOCURSOR);

if(getch()=='c' || getch()=='c')

{

menu();

}

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

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 113/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   1   3

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

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 114/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   1   4

{

if((stricmp(input,access.accCompany)==0) &&

(stricmp(input1,access.accModel)==0))

{

flag=1;

textcolor(YELLOW);

gotoxy(15,12);

cprintf("%s",access.accCompany);

gotoxy(30,12);

cprintf("%s",access.accModel);

gotoxy(45,12);

cprintf("%s",access.accPrice);

gotoxy(60,12);

cprintf("%s",access.accQuantity);

y++;

}

}

if(flag==0) // if the record was not found

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 115/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   1   5

{

gotoxy(30,43);

textcolor(YELLOW);

cprintf("Record not found!");

}

fclose(fp);

textcolor(YELLOW);

gotoxy(25,41);

cprintf("Press any key to go to menu!");

getch();

menu();

}

//############################UPDATE

ACCESSORIES##########################//

void updateAccessories()

{

FILE *fp;

int flag=0;

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 116/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   1   6

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);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 117/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   1   7

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();

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 118/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   1   8

menu();

}

while(fread(&access,size,1,fp)!=0) //fread returning zero means, the file has reached the end

{

if((stricmp(input,access.accCompany)==0) &&

(stricmp(input1,access.accModel)==0))

{

flag=1;

 break;

}

}

if(flag==0) // if the record was not found

{

gotoxy(24,42);

textcolor(YELLOW);

cprintf("Record not found!");

getch();

menu();

}

//ASK for the confirmation to modify

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 119/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   1   9

gotoxy(27,42);

cprintf("Update the record? (y/n)");

fflush(stdin);

yesno=getche();

if(yesno=='y' || yesno=='Y')

{

//modifying steps

//scanning the values from user 

 _setcursortype(_SOLIDCURSOR);

gotoxy(34,26);

fflush(stdin);

scanPrice(access.accPrice);

gotoxy(34,30);

fflush(stdin);

scanQuantity(access.accQuantity);

//seek one record up

fseek(fp,-size,SEEK_CUR);

//write the modified record into the file

fwrite(&access,size,1,fp);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 120/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   2   0

}

else

{

menu();

}

fclose(fp);

textcolor(GREEN);

gotoxy(25,43);

cprintf("Record updated successfully!");

textcolor(YELLOW);

gotoxy(25,44);

cprintf("Press any key to go to menu!");

getch();

menu();

}

//###########################DELETE

ACCESSORIES############################//

void deleteAccessories()

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 121/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   2   1

{

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);

textcolor(WHITE);

gotoxy(34,5);

cprintf("Delete Accessories");

gotoxy(10,20);

cprintf("Company: ");

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 122/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   2   2

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);

 _setcursortype(_NOCURSOR);

add=getch();

if(add=='c' || add=='c')

{

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 123/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   2   3

menu();

}

clrscr();

textcolor(YELLOW);

makeBox(20,40,40,5);

makeBox(31,4,17,2);

makeBox(10,7,60,30);

gotoxy(34,5);

textcolor(WHITE);

cprintf("Delete Screen");

gotoxy(20,39);

textcolor(WHITE);

cprintf("Info");

textcolor(YELLOW);

gotoxy(25,9);//statics tile

cprintf("Company");

gotoxy(50,9);

cprintf("Model");

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 124/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   2   4

fp=fopen("Accessories.dat","rb+");//opens Instruments.dat file

if(fp==NULL) //if anycase the file cannot be opened

{

gotoxy(16,42);

textcolor(RED);

cprintf("File not found!");

getch();

menu();

exit(0);

}

while(fread(&access,size,1,fp)!=0)//read file

{

if((stricmp(input,access.accCompany)==0) &&

(stricmp(input1,access.accModel)==0))

{

flag=1;

gotoxy(25,y);

cprintf("%s",access.accCompany);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 125/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   2   5

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

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 126/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   2   6

rewind(fp); //rewind the original file InsChart.dat

//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);

//delete the original file

remove("Accessories.dat");

//rename the temp.dat to Instruments.dat

rename("temp.dat","Accessories.dat");

gotoxy(25,43);

textcolor(GREEN);

cprintf("Record deleted successfully!");

getch();

menu();

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 127/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   2   7

}

else

{

gotoxy(27,43);

textcolor(YELLOW);

cprintf("Record not deleted!");

getch();

menu();

}

}

//##########################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);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 128/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   2   8

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();

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 129/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   2   9

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;

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 130/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   3   0

case '4':

{

deleteParts();

}break;

case '5':

{

menu();

}break;

}

getch();

}

//#########################ADD PARTS############################//

void addParts()

{

FILE *fp;

long int size;

char add;

char exit;

size=sizeof(part);

clrscr();

textcolor(YELLOW);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 131/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   3   1

makeBox(18,40,46,5);

makeBox(32,4,12,2);

makeBox(6,15,69,15);

textcolor(DARKGRAY);

makeBox(2,2,77,47);

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);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 132/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   3   2

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);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 133/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   3   3

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

{

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 134/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   3   4

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()

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 135/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   3   5

{

FILE *fp;

int y=7;

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);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 136/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   3   6

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");

 _setcursortype(_SOLIDCURSOR);

gotoxy(23,14);

scanCompany(input);

gotoxy(23,18);

scanModel(input1);

 _setcursortype(_NOCURSOR);

if(getch()=='c' || getch()=='c')

{

menu();

}

clrscr();

textcolor(DARKGRAY);

makeBox(2,2,77,47);

textcolor(YELLOW);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 137/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   3   7

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+");

if(fp==NULL) // if the file couldn't be opened

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 138/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   3   8

{

textcolor(YELLOW);

gotoxy(30,43);

cprintf("File not found!");

getch();

menu();

}

while(fread(&part,size,1,fp)!=0) //fread returning zero means, the file has reached the end

{

if((stricmp(input,part.partCompany)==0) &&

(stricmp(input1,part.partModel)==0))

{

flag=1;

textcolor(YELLOW);

gotoxy(15,12);

cprintf("%s",part.partCompany);

gotoxy(30,12);

cprintf("%s",part.partModel);

gotoxy(45,12);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 139/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   3   9

cprintf("%s",part.partPrice);

gotoxy(60,12);

cprintf("%s",part.partQuantity);

y++;

}

}

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);

cprintf("Press any key to go to menu!");

getch();

menu();

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 140/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   4   0

}

//############################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);

textcolor(WHITE);

gotoxy(34,5);

cprintf("Update Parts");

gotoxy(10,12);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 141/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   4   1

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);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 142/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   4   2

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

{

if((stricmp(input,part.partCompany)==0) &&

(stricmp(input1,part.partModel)==0))

{

flag=1;

 break;

}

}

if(flag==0) // if the record was not found

{

gotoxy(24,42);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 143/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   4   3

textcolor(YELLOW);

cprintf("Record not found!");

getch();

menu();

}

//ASK for the confirmation to modify

gotoxy(27,42);

cprintf("Update the record? (y/n)");

fflush(stdin);

yesno=getche();

if(yesno=='y' || yesno=='Y')

{

//modifying steps

//scanning the values from user 

 _setcursortype(_SOLIDCURSOR);

gotoxy(34,26);

fflush(stdin);

scanPrice(part.partPrice);

gotoxy(34,30);

fflush(stdin);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 144/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   4   4

scanQuantity(part.partQuantity);

//seek one record up

fseek(fp,-size,SEEK_CUR);

//write the modified record into the file

fwrite(&part,size,1,fp);

}

else

{

menu();

}

fclose(fp);

textcolor(GREEN);

gotoxy(25,43);

cprintf("Record updated successfully!");

textcolor(YELLOW);

gotoxy(25,44);

cprintf("Press any key to go to menu!");

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 145/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   4   5

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);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 146/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   4   6

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);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 147/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   4   7

fflush(stdin);

scanModel(input1);

 _setcursortype(_NOCURSOR);

add=getch();

if(add=='c' || add=='c')

{

menu();

}

clrscr();

textcolor(YELLOW);

makeBox(20,40,40,5);

makeBox(31,4,17,2);

makeBox(10,7,60,30);

gotoxy(34,5);

textcolor(WHITE);

cprintf("Delete Screen");

gotoxy(20,39);

textcolor(WHITE);

cprintf("Info");

textcolor(YELLOW);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 148/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   4   8

gotoxy(25,9);//statics tile

cprintf("Company");

gotoxy(50,9);

cprintf("Model");

fp=fopen("Parts.dat","rb+");//opens Instruments.dat file

if(fp==NULL) //if anycase the file cannot be opened

{

gotoxy(16,42);

textcolor(RED);

cprintf("File not found!");

getch();

menu();

exit(0);

}

while(fread(&part,size,1,fp)!=0)//read file

{

if((stricmp(input,part.partCompany)==0) &&

(stricmp(input1,part.partModel)==0))

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 149/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   4   9

{

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);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 150/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   5   0

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

rewind(fp); //rewind the original file InsChart.dat

//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);

//delete the original file

remove("Parts.dat");

//rename the temp.dat to Instruments.dat

rename("temp.dat","Parts.dat");

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 151/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   5   1

gotoxy(25,43);

textcolor(GREEN);

cprintf("Record deleted successfully!");

getch();

menu();

}

else

{

gotoxy(27,43);

textcolor(YELLOW);

cprintf("Record not deleted!");

getch();

menu();

}

}

//#########################SCAN COMPANY###############################//

void scanCompany(char *Company)//custom scanf function for names

{

char input[50];

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 152/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   5   2

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

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 153/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   5   3

{

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

{

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 154/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   5   4

 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>=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

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 155/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   5   5

//###########################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();

}

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 156/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   5   6

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#################################//

void scanQuantity(char *Quantity)//custom scanf function for names

{

char input[50];

char in;

int count=0;

do

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 157/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   5   7

{

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;

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 158/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   5   8

}

count++;

}while(count<50);

input[count]='\0';

strcpy(Quantity,input);//co

}

//#########################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);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 159/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   5   9

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)))

{

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

//########################SCAN PASSWORD#######################//

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 160/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   6   0

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)))

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 161/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   6   1

{

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);

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 162/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   6   2

//top right corner 

gotoxy(x+width,y);

cprintf("%c",191);

//bottom left corner 

gotoxy(x,y+height);

cprintf("%c",192);

//bottom right corner 

gotoxy(x+width, y+height);

cprintf("%c",217);

for(i=x+1;i<x+width;i++)

{

//for top line

gotoxy(i,y);

cprintf("%c",196);

//for bottom line

gotoxy(i,y+height);

cprintf("%c",196);

}

for(j=y+1;j<y+height;j++)

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 163/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   6   3

{

//for left line

gotoxy(x,j);

cprintf("%c",179);

//for right line

gotoxy(x+width, j);

cprintf("%c",179);

}

}

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 164/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   6   4

TESTING

Test Plan

Test

Case

No:

Description

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 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. Test to confirm that the laptop records are deleted by searching again.

10. 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.

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 165/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   6   5

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. Test to confirm that the cellphone records are deleted by searching again.

17. 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 inthe 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. Test to confirm that the accessory records are deleted by searching again.

24. Test if the Main Menu appears when option 5 is selected in the Manage

Accessories screen.

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 166/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   6   6

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. Test to confirm that the part records are deleted by searching again.

31. 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.

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 167/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   6   7

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.

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 168/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   6   8

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 Expected: Delete Laptops screen and Delete screen must appear.

Result Shown: Delete Laptops screen and Delete screen appears.

Conclusion: The result was shown as expected.

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 169/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   6   9

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.

Conclusion: The result was shown as expected.

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 170/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   7   0

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 Expected: µRecord not found¶ message should appear.

Result Shown: µRecord not found¶ message appears.

Conclusion: The result was shown as expected.

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 171/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   7   1

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

Show Search screen.

Result Shown: Search/List Accessories screen appears and records are shown.

Conclusion: The result was shown as expected.

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 172/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   7   2

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.

Result Shown: Main menu appears.

Conclusion: The result was shown as expected.

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 173/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   7   3

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 Expected: Update Parts screen must appear and details must be updated.

Result Shown: Update Parts screen appears and details are updated.

Conclusion: The result was shown as expected.

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 174/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   7   4

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.

Conclusion: The result was show as expected.

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 175/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   7   5

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.

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 176/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   7   6

Test Log

Test

Case

No:

Description Outcome

1. Test if the authentication screen appears when a key is pressed in the

start-up splash screen.

Done

2. Test if the authentication is denied when username and password entered

is incorrect.

Done

3. Test if the Main Menu appears when the username and password are

accepted.

Done

4. Test if the Manage Laptops screen appears when option 1 is entered in

the Main Menu.

Done

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.

Done

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.

Done

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.

Done

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.

Done

9. Test to confirm that the laptop records are deleted by searching again. Done

10. Test if the Main Menu appears when option 5 is selected in the ManageLaptops screen.

Done

11. Test if the Manage Cellphones screen appears when option 2 is entered in

the Main Menu.

Done

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 177/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   7   7

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. Test to confirm that the cellphone records are deleted by searching again. Done

17. Test if the Main Menu appears when option 5 is selected in the Manage

Cellphones screen.

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 isentered 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. Test to confirm that the accessory records are deleted by searching again. Done

24. Test if the Main Menu appears when option 5 is selected in the Manage

Accessories screen.

Done

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 178/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   7   8

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. Test to confirm that the part records are deleted by searching again. Done

31. Test if the Main Menu appears when option 5 is selected in the Manage

Parts screen.

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

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 179/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   7   9

IMPLEMENTATION

Hardware & Software Specifications

Hardware

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

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 180/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   8   0

User Instruction Manual

Note: Company¶s name and model must be entered in Uppercase or Capital letters. Lowercase

letters are not accepted. Numbers are also not accepted in Company¶s name.

1. Splash Screen appears when the program is run. Press any key in the splash screen to go to

authentication screen.

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 181/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   8   1

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.

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 182/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   8   2

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.

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 183/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   8   3

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.

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 184/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   8   4

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.

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 185/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   8   5

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.

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 186/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   8   6

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.

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 187/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   8   7

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.

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 188/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   8   8

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.

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 189/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   8   9

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.

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 190/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   9   0

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.

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 191/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   9   1

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.

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 192/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   9   2

12. To go back to main menu from Manage screen press 5.

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 193/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   9   3

13. In the main menu, press 5 to log out and go to Authentication screen.

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 194/195

BIRAT LAL SHRESTHA (1801T3100045) 

INTRODUCTION TO C (CPG102)

   1   9   4

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.

8/6/2019 CPG102 Birat Lal Shrestha 1801T3100045

http://slidepdf.com/reader/full/cpg102-birat-lal-shrestha-1801t3100045 195/195

BIRAT LAL SHRESTHA (1801T3100045) 

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 O l d b h d d li d i