77
Project Report On School Automation System Submitted in partial fulfillment of the Requirement for the award of the degree of Bachelor of technology BPUT, BBSR 20XX-20XX UNDER THE GUIDANCE OF SUBMITTED BY Er. Xxxxx Xxxxx Xxxxx Mr. Xxxxx Xxxx Roll No:

school automation system

Embed Size (px)

Citation preview

Page 1: school automation system

Project Report On

School Automation System

Submitted in partial fulfillment of the Requirement for the award of the degree of

Bachelor of technology

BPUT, BBSR 20XX-20XX

UNDER THE GUIDANCE OF SUBMITTED BY Er. Xxxxx Xxxxx Xxxxx Mr. Xxxxx Xxxx

Roll No:

Page 2: school automation system

CERTIFICATE

This is to certify that the project report entitled “School Automation System” that is being submitted by Mr. Xxxxxxxxxx Xxxxxxxx in partial fulfillment for the award of the Degree of Master of Technology in Xxxxx Institute of Technology affiliated to the Biju Patnaik University of Technology is a record of bonafide work carried out by him under my guidance and supervision. The results embodied in this project report have not been submitted to any other University or Institute for the award of any degree or diploma.

Mr.Xxxxx Xxxxxx (Project Leader)

Mr. Xxxxxxxx Xxxxxx Mr. Xxxxx Xxxx (Project Coordinator) (Project Coordinator)

SR Info Systems, Bhubaneswar

Date:

Page 3: school automation system

ACKNOWLEDGEMET

We are very grateful to SR Info Systems, Bhubaneswar for providing us an We are very grateful to SR Info Systems, Bhubaneswar for providing us an

opportunity to complete our project. We highly acknowledge the guidance opportunity to complete our project. We highly acknowledge the guidance

and inputs provided to us by and inputs provided to us by Mr. Xxxxxx Xxxxxx (Project Leader, SR Info (Project Leader, SR Info

Systems, Bhubaneswar) for whose support we are highly indebted.Systems, Bhubaneswar) for whose support we are highly indebted.

We also owe our gratitude to Mr. Xxxxx XxxxMr. Xxxxx Xxxx our Project Coordinator for his kind guidance, and enabling us to complete our project. On the whole this project is a group endeavor and we acknowledge theOn the whole this project is a group endeavor and we acknowledge the cooperation of each other. cooperation of each other.

Thanking all of you……

Date:

Place:

Page 4: school automation system

Table of Contents

Sl. No Page

1. Introduction 00o Project Title

00o A Bird View

00o Strict Schedule

00o Introduction to Project

00o Organization Profile

00o Purpose of the System

00o Quick View

002. Software and Platform Used 00

o C++ 00

3. Program 004. System Testing 00

o Testing Methodology 00

o Unit Testing 00

o White Box Testing 00

o Conditional Testing 00

o Loop Testing 00

Page 5: school automation system

o Validation Testing 00

o Black Box Testing 00

o Performance and Acceptance Testing 00

o System Testing 00

5. Conclusion 00o Merits of the Project 00

o Limitations of the Project 00

o Future Extension 00

TITLE:

“SCHOOL AUTOMATION SYSTEM”

A BIRDS’ EYEVIEW:

A database management system. Only our authorized administrator has full rights to generate users. Ten input fields of different data types. Whole administration system is managed by proper filing. It has an independent password function, which executes right at the

start of the program. Data duplication is put out of action by the key field. User-friendly handling and interface.

Page 6: school automation system

Whole program is facilitated by keyboard as well as mouse where necessary.

Security aspect got our first priority.

STRICT SCHEDULE:

We have followed a strict time frame as mentioned in our project proposal. Ample time has given to analysis, coding and debugging.

INTRODUCTION TO PROJECT: School Automation System

Let us go through this system in detail.

1. User defined data type:

First we have created a user defined data type. In this data type we define further different sub data types, which were used effectively in this program.

2. Filing:

Since our whole software is based on filing therefore we gave great emphasis to it. We create, open, rename, delete and close file frequently in this project. We used different modes of filing like W, R, A, B.

3. Data duplication phenomenon:

In this program we restrict our primary key to one field only i.e. G.R.no, which is unique throughout the program. Hence, through this tool we were successful to overcome the duplicity phenomenon. This factor is discussed in detail later in ‘ADDREC’ function.

4. Autonomous Password Function:

We have created an independent password evaluation function pass(), where we replace input character by ‘*’, which is quite handy in hiding the

Page 7: school automation system

information from other viewers. We have provided a “backspace” option here, through which, we can erase incorrect password entered while typing.

5. Functions And Their Usage Functions used:

We have used nine user-defined functions in this project. 1. Addrec(); 2. Display single record ();

3. Display all record(); 4. Edit record(); 5. Delete record(); 6. Pass(); 7. Add_user(); 8. Delete_user(); 9. Display_user();ADDREC();

Through this function we insert records according to eight different fields. In those fields G.R.no. is our primary key, which is unique throughout the program. Hence, through this tool we were successful to overcome the duplicity phenomenon. EDIT RECORD();

This function enables us to edit records. We can edit only those records, which already exists in the data base. Than G.R.no. is asked, so that it can display required record for editing. When the required record is displayed you can than edit the fields you want to and after saving the changes you can than return to main menu.

DISPLAY SINGLE RECORD();

It is used to display the particular single record which will specified by the user through G.R.no. The required record according to entered G.R.no. is than displayed on the screen.

DISPLAY ALL RECORD();This function Facilitate us to view all records present in the database one by one by following the instructions.

DELETE RECORD():

Page 8: school automation system

Through this function we can delete the required record by specifying the corresponding G.R.no. after that the record is destroyed.PASS();Through this function we can create a password program. In this password pragram input character is replaced by ‘*’ automatically. For this purpose we use strcmp() function.ADD_USER(); The administrator only accesses this function. He will add users with the help of this function by assigning him a unique name and password and saving his name and password in the file userfile.dat..DELETE_USER ();Administrator will delete the user by deleting his name and password from the file userfile.dat so that he will not be able to access the records of students again.DISPLAY_USER ();Administrator uses this function to see the names and passwords of authorized user.6. Filing.We have used two different files in this project.

1. student.dat2. userfile.dat

In student.dat, administrator will record all the information of the student. The information of the student is recorded by saving following characteristics of students. We name these characteristics as different fields.

1. Roll number.2. Name.3. Father’s Name.4. Gender.5. Address.6. Phone number.7. Date of admission8. Class.

In userfile.dat, administrator will record the names and passwords of different users and than correspond where it wanted to.7. Administrator:Administrator is the person with a unique password. He will maintain the record of students and also manage the users who can access the record.

Page 9: school automation system

Administrator can record the information about a partiticular student on the file student.dat or in other words he can add, edit, delete and can see the saved records in the file student.dat.

Administrator will also manage the access of authorized users. He will allow a user to access the records of students in student.dat file by adding the user in the file user.dat by assigning him a unique password.

8. Authorized users:Users are persons with unique usernames and passwords and can access the records of students saved in the file student.dat. The administrators who manage their ID and passwords in the file user.dat add them. Their access is limited as they can only look in the record or can only search for the specified record. 9. Security aspect:Since security is one of the important building blocks of a database therefore from beginning we put stress on this issue. Since our administration database is a computer base therefore we did not use any specified encryption algorithm as in networks however we use .dat format to save our data, which is unable to access.

ORGANIZATION PROFILE

Software Solutions is an IT solution provider for a dynamic environment

where business and technology strategies converge. Their approach focuses

on new ways of business combining IT innovation and adoption while also

leveraging an organization’s current IT assets. Their work with large global

corporations and new products or services and to implement prudent

business and technology strategies in today’s environment.

SR Info system’s RANGE OF EXPERTISE INCLUDES:

Software Development Services

Engineering Services

Systems Integration

Page 10: school automation system

Customer Relationship Management

Product Development

Electronic Commerce

Consulting

IT Outsourcing

We apply technology with innovation and responsibility to achieve two

broad objectives:

Effectively address the business issues our customers face today.

Generate new opportunities that will help them stay ahead in the

future.

THIS APPROACH RESTS ON:

A strategy where we architect, integrate and manage technology

services and solutions - we call it AIM for success.

A robust offshore development methodology and reduced

demand on customer resources.

A focus on the use of reusable frameworks to provide cost and

times benefits.

They combine the best people, processes and technology to achieve

excellent results - consistency. We offer customers the advantages of:

SPEED:

They understand the importance of timing, of getting there before the

competition. A rich portfolio of reusable, modular frameworks helps jump-

start projects. Tried and tested methodology ensures that we follow a

predictable, low - risk path to achieve results. Our track record is testimony

to complex projects delivered within and evens before schedule.

EXPERTISE:

Page 11: school automation system

Our teams combine cutting edge technology skills with rich domain

expertise. What’s equally important - they share a strong customer

orientation that means they actually start by listening to the customer.

They’re focused on coming up with solutions that serve customer

requirements today and anticipate future needs.

A FULL SERVICE PORTFOLIO:They offer customers the advantage of being able to Architect,

integrate and manage technology services. This means that they can rely on one, fully accountable source instead of trying to integrate disparate multi vendor solutions.SERVICES:

SR Infosystems is providing its services to companies which are in the field of production, quality control etc with their rich expertise and experience and information technology they are in best position to provide software solutions to distinct business requirements.Quality:

At SR Infosystems, we believe in Quality as much as we talk about it.

Our objective is to deliver the highest possible quality projects and

solutions that meet or exceed our customer expectations. Quality, to us, is

not a mere business pulling strategy but a standard to be practiced by

everyone in the organizational hierarchy.

Our Quality Management Systems are based on the best of industry

standard quality guidelines. Moreover the quality management concept

evolves from practical on-the-job lessons and the organization’s strategy. Its

implementation is effectively managed through a comprehensive, practical

and well-designed process. Constant review and audit of this system ensures

its applicability and use throughout the organization.

We also realize that, by just testing software we will not make the

software any better or improve its quality. Hence our employees are

educated and motivated to incorporate the quality processes into their

Page 12: school automation system

everyday activities, thereby preventing non-conformance to quality at every

level. The active QA department and compulsory QA on every project, help

monitor and evaluate quality at every stage. Any deviation is dedicated and

corrected at an early stage.

Purpose of the System:

School Automation System Software is basically meant for store the

Employee information and users show the employee details.

School Automation System Software is reliable, flexible, portable,

reusable and adaptable software. Its reliability is due to its effective data

recovery (when data is corrupted) and higher security provisions. This

software is highly adaptable to Windows Environment. For maintenance of

our software extensive documentation will be provided.

A quick View:

Software and Platform Used

C++

1. A First Program2. Loops

Page 13: school automation system

3. Symbolic Constants4. Conditionals5. Pointers6. Arrays7. Character Arrays8. Functions9. File10. Command-line Arguments11. Graphical Interfaces: Dialog Boxes

1. A First Program

Let's be polite and start by saluting the world! Type the following program into your favorite editor:

#include < stdio.h>#include < iostream.h>

void main(){printf("\nHello World\n");}

Save the code in the file hello.cpp, then compile it by typing:gcc hello.cpp This creates an executable file about, which is then executed simply by typing its name. The result is that the characters “Hello World” are printed out, preceded by an empty line. A C++ program contains functions and variables. The functions specify the tasks to be performed by the program. The “main” function establishes the overall logic of the code. It is normally kept short and calls different functions to perform the necessary sub-tasks. All C++ codes must have a “main” function. Our hello.cpp code calls printf, an output function from the I/O (input/output) library (defined in the file stdio.h, iostream.h). The original C++ language did not have any built -in I/O statements whatsoever. Nor did it have much arithmetic functionality. The original language was really not intended for “scientific” or “technical” computation.. These functions are now performed by standard libraries, which are now part of ANSI C++. The textbook lists the content of these and other standard libraries in an appendix. The printf line prints the message “Hello World” on “stdout” (the output stream corresponding to the X - terminal window in which you run the code); “\n” prints a “new line” character, which brings the cursor onto the next line. By construction, printf never inserts this character on its own: the following program would produce the same result:

#include < stdio.h>#include < iostream.h>

Page 14: school automation system

void main(){printf("\n");printf("Hello World");printf("\n");}

Try leaving out the “\n” lines and see what happens. The first statement “#include <stdio.h>” “#include <iostream.h>” includes a specification of the C++ I/O library. All variables in C++ must be explicitly defined before use: the “.h” files are by convention “header files” which contain definitions of variables and functions necessary for the functioning of a program, whether it be in a user -written section of code, or as part of the standard C++ libaries. The directive “#include” tells the C++ compiler to insert the contents of the specified file at that point in the code. The “< ...>” notation instructs the compiler to look for the file in certain “standard” system directories. The void preceeding “main” indicates that main is of “void” type--that is, it has no type associated with it, meaning that it cannot return a result on execution. The “;” denotes the end of a statement. Blocks of statements are put in braces {...}, as in the definition of functions. All C++ statements are defined in free format, i.e., with no specified layout or column assignment. Whitespace (tabs or spaces) is never significant, except inside quotes as part of a character string. The following program would produce exactly the same result as our earlier example:

#include < stdio.h>#include < iostream.h>

void main(){printf("\nHello World\n");}

The reasons for arranging your programs in lines and indenting to show structure should be obvious!

2. Loops

Most real programs contain some construct that loops within the program, performing repetitive actions on a stream of data or a region of memory. There are several ways to loop in C++. Two of the most common are the while loop:

while (expression){...block of statements to execute...

Page 15: school automation system

}and the for loop:for (expression_1; expression_2; expression_3){...block of statements to execute...}

The while loop continues to loop until the conditional expression becomes false. The ondition is tested upon entering the loop. Any logical construction (see below for a list) can be used in this context. The for loop is a special case, and is equivalent to the following while loop:

expression_1;while (expression_2){...block of statements...expression_3;}For instance, the following structure is oftenencountered:i = initial_i;while (i <= i_max){...block of statements...i = i + i_increment;}This structure may be rewritten in the easier syntax ofthe for loop as:for (i = initial_i; i <= i_max; i = i + i_increment){...block of statements.. .}

Infinite loops are possible (e.g. for(;;)), but not too good for your computer budget! C++ permits you to write an infinite loop, and provides the break statement to “breakout “ of the loop. For example, consider the following (admittedly not -so-clean) re-write of theprevious loop:

angle_degree = 0;for ( ; ; ){...block of statements...angle_degree = angle_degree + 10;

Page 16: school automation system

if (angle_degree == 360) break;}

The conditional if simply asks whether angle_degree is equal to 360 or not; if yes, the loop is stopped.

3. Symbolic Constants

You can define constants of any type by using the #define compiler directive. Its syntax is simple –for instance

#define ANGLE_MIN 0#define ANGLE_MAX 360

would define ANGLE_MIN and ANGLE_MAX to the values 0 and 360, respectively. C++ distinguishes between lowercase and uppercase letters in variable names. It is customary to use capital letters in defining global constants.

4. Conditionals

Conditionals are used within the if and while constructs:

if (conditional_1){...block of statements executed if conditional_1 istrue...}else if (conditional_2){...block of statements executed if conditional_2 istrue...}else{...block of statements executed othe rwise...}

and any variant that derives from it, either by omitting branches or by including nested conditionals. Conditionals are logical operations involving comparison of quantities (of the same type) using the conditional operators:

< smaller than<= smaller than or equal to== equal to

Page 17: school automation system

!= not equal to>= greater than or equal to> greater than and the boolean operators&& and || or ! not

Another conditional use is in the switch construct:

switch (expression){case const_expression_1:{...block of statements...break;}case const_expression_2:{...block of statements...break;}default:{...block of statements..}}

The appropriate block of statements is execute the according to the value of the expression, compared with the constant expressions in the case statement. The break statements insure that the statements in the cases following the chosen one will not be executed. If you would want to execute these stateme nts, then you would leave out the break statements. This construct is particularly useful in handling input variables.

5. Pointers

The C++ language allows the programmer to “peek and poke” directly into memory locations. This gives great flexibility and power to the language, but it also one of the great hurdles that the beginner must overcome in using the language. All variables in a program reside in memory; the statements float x; x = 6.5; request that the compiler reserve 4 bytes of memo ry (on a 32-bit computer) for the floating -point variable x, thenput the “value” 6.5 in it. Sometimes we want to know where a variable resides in memory. The address (location in memory) of any variable is obtained by placing the operator “&” before its name. Therefore &x is the address of x. C++ allows us to go one

Page 18: school automation system

stage further and define a variable, called a pointer, that contains the address of (i.e. “points to”) other variables. For example:

float x;float* px;x = 6.5;px = &x;

defines px to be a pointer to objects of type float, and sets it equal to the address of x:Pointer use for a variable The content of the memory location referenced by a pointer is obtained using the “*” operator (this is called dereferencing the pointer). Thus, *px refers to the value of x. C++ allows us to perform arithmetic operations using pointers, but beware that the “unit” in pointer arithmetic is the size (in bytes) of the object to whichthe pointer points. For example, if px is a pointer to a variable x of type float, then the expression px + 1 refers not to the next bit or byte in memory but to the location of the next float after x (4 bytes away on most workstations); if x were of type double, then px + 1 would refer to a location 8 bytes (the size of a double)away, and so on. Only if x is of type char will px + 1 actually refer to the next byte in memory. Thus, in

char* pc;float* px;float x;x = 6.5;px = &x;pc = (char*) px;

(the (char*) in the last line is a “cast”, which converts one data type to another), px and pc both point to the same location in memory --the address of x--but px + 1and pc + 1 point to different memory locations. Consider the following simple code.

void main(){float x, y; /* x and y are offloat type */float *fp, *fp2; /* fp and fp2 are pointersto float */x = 6.5; /* x now contains thevalue 6.5 *//* print contents andaddress of x */printf("Value of x is %f, address of x %ld \n", x, &x);fp = &x; /* fp now points tolocation of x */

Page 19: school automation system

/* print the contents of fp */printf("Value in memory l ocation fp is %f\n", *fp);/* change content ofmemory location */*fp = 9.2;printf("New value of x is %f = %f \n", *fp, x);/* perform arithmetic*/*fp = *fp + 1.5;printf("Final value of x is %f = %f \n", *fp, x);/* transfer values*/y = *fp;fp2 = fp;printf("Transfered value into y = %f and fp2 = %f \n",y, *fp2);}

Run this code to see the results of these different operations. Note that, while the value of a pointer ( if you print it out with printf) is typically a large integer, denoting some particular memory location in the computer, pointers are not integers--they are acompletely different data type.

6. Arrays

Arrays of any type can be formed in C. The syntax is simple:

type name[dim];

In C++, arrays start at position 0. The elements of the array occupy adjacent locations in memory. C treats the name of the array as if it were a pointer to the first element--this is important in understanding how to do arithmetic with arrays. Thus, if v is an array, *v is the same thing as v[0], *(v+1) is the same thing as v[1], and so on:

Pointer use for an array Consider the following code, which illustrates the use of pointers:

#define SIZE 3void main(){float x[SIZE];float *fp;int i;/* initialize the array x

Page 20: school automation system

*//* use a "cast" to force i*//* into the equivalent float*/for (i = 0; i < SIZE; i++)x[i] = 0.5*(float)i;/* print x */for (i = 0; i < SIZE; i++)printf(" %d %f \n", i, x[i]);/* make fp point to array x*/fp = x;/* print via pointerarithmetic *//* members of x areadjacent to *//* each other in memory *//* *(fp+i) refers to contentof *//* memory location (fp+i)or x[i] */for (i = 0; i < SIZE; i++)printf(" %d %f \n", i, *(fp+i));}(The expression ``i++'' is C shorthand for ``i = i + 1''.) Since x[i] means the i-th element of the array x, and fp = x points to the start of the x array, then *(fp+i) is the content of the memory address i locations beyond fp, that is, x[i].

7. Character Arrays

A string constant, such as “I am a string" is an array of characters. It is represented internally in C++ by the ASCII characters in the string, i.e., “I”, blank, “a”, “m”,... for the above string, and terminated by the special null character ``\0'' so programs can find theend of the string. String constants are often used in making the output of code intelligible using printf ;

printf("Hello, world\n");printf("The value of a is: %f \n", a);

String constants can be associ ated with variables. C++ provides the char type variable, which can contain one character--1 byte--at a time. A character string is stored in an array of character type, one ASCII character per location. Never forget that, since strings are conventionally terminated by the null character “\0”, we require one extra storage

Page 21: school automation system

location in the array! C++ does not provide any operator which manipulates entire strings at once. Strings are manipulated either via pointers or via special routines available from the standard string library string.h. Using character pointers is relatively easy since the name of an array is a just a pointer to its first element.

8. Functions

Functions are easy to use; they allow complicated programs to be parcelled up into small blocks, each of which is easier to write, read, and maintain. We have already encountered the function main and made use of I/O and mathematical routines from the standard libraries. Now let's look at some other library functions, and how to write and use our own. Calling a Function The call to a function in C++ simply entails referencing its name with the appropriate arguments. The C++ compiler checks for compatibility between the arguments in the calling sequence and the definition of the function.Library functions are generally not available to us in source form. Argument type checking is accomplished through the use of header files (like stdio.h) whichcontain all the necessary information. For example, as we saw earlier, in order to use the standard mathematical library you must include math.h via the statement

#include < math.h>at the top of the file containing your code. The most commonly used header files are

< stdio.h> -> defining I/O routines< ctype.h> -> defining character manipulation routines< string.h> -> defining string manipulation routines< math.h> -> defining mathematical routines< stdlib.h> -> defining number conversion, storage allocation and similar tasks< stdarg.h> -> defining libraries to handle routines with variable numbers of arguments< time.h> -> defining time-manipulation routines In addition, the following header files exist:< assert.h> -> defining diagnostic routines< setjmp.h> -> defining non-local function calls< signal.h> -> defining signal handlers< limits.h> -> defining constants of the int type< float.h> -> defining constants of the float type Appendix B in the K & R book describes these libraries in great detail. Writing Your Own Functions A function has the following layout:

return-type function-name ( argument-list-if-necessary ){...local-declarations......statements...return return-value;

Page 22: school automation system

}

If return-type is omitted, C++ defaults to int. The return value must be of the declared type. A function may simply perform a task without returning any value, in which case it has the following layout:

void function-name ( argument-list-if-necessary ){...local-declarations......statements...}As an example of function calls, consider the following code:

/* include headers of library *//* defined for all routines *//* in the file */#include < stdio.h>#include < string.h>/* prototyping of functions *//* to allow type checks by *//* the compiler */void main(){int n;char string[50];/* strcpy(a,b) copies string b into a *//* defined via the stdio.h header */strcpy(string, "Hello World");/* call own function */n = n_char(string);printf("Length of string = %d\n", n);}/* definition of local function n_ch ar */int n_char(char string[]){/* local variable in this function */int n;/* strlen(a) returns the length of *//* string a *//* defined via the string.h header */n = strlen(string);if (n > 50)printf("String is longer than 50 characters \n");/* return the value of integer n */

Page 23: school automation system

return n;}

Arguments are always passed by value in C++ function calls. This means that local “copies” of the values of the arguments are passed to the rout ines. Any change madeto the arguments internally in the function are made only to the local copies of the arguments. In order to change (or define) an argument in the argument list, thisargument must be passed as an address, thereby forcing C++ to change the “real” argument in the calling routine. As an example, consider exchanging two numbersbetween variables. First let's illustrate what happen if the variables are passed by value:

#include < stdio.h>void exchange(int a, int b);void main(){ /* WRONG CODE */int a, b;a = 5;b = 7;printf("From main: a = %d, b = %d \n", a, b);exchange(a, b);printf("Back in main: ");printf("a = %d, b = %d\n", a, b);}void exchange(int a, int b){int temp;temp = a;a = b;b = temp;printf(" From function exchange: ");printf("a = %d, b = %d\n", a, b);}

Run this code and observe that a and b are NOT exchanged! Only the copies of the arguments are exchanged. The RIGHT way to do this is of course to use pointers:

#include < stdio.h>void exchange ( int *a, int *b );void main(){ /* RIGHT CODE */int a, b;a = 5;b = 7;printf("From main: a = %d, b = %d \n", a, b);

Page 24: school automation system

exchange(&a, &b);printf("Back in main: ");printf("a = %d, b = %d\n", a, b);}void exchange ( int *a, int *b ){int temp;temp = *a;*a = *b;*b = temp;printf(" From function exchange: ");printf("a = %d, b = %d\n", *a, *b);}

The rule of thumb here is that You use regular variables if the function does not change the values of those

arguments You MUST use pointers if the function changes the values of those arguments

9. File

* A file is a collection of related data stored in a particular area on the disk. * Files are used to store data permanently on parmanent storage devices like as hard disk.

Classes For File Stream Operations:The I/O system of C++ contains a set of classes that define the file handling

methods. These include ifstream, ofstream and fstream. These classes, designed to manage the disk files, are declared in fstream.h and therefore we must include this file in any program that uses files.

iostream

ostreamistream

ios

ifstream ofstreamfstream

Page 25: school automation system

ifstream: Provides input operations. Contains open() with default input mode. Inherit the functions get(), getline(), read(), seekg() and tellg() functions from istream.

ofstream: Provides output operations. Contains open() with default output mode. Inherits put(), seekp(), tellp() and write() functions from ostream.

fstream: Provides support for simultaneous input and output operations. Contains open() with default input mode. Inherits all the functions from istream and ostream classes through iostream.

Opening and Closing a file:A file can be opened in two ways:

1. Using the constructor function of the class.2. Using the member function open() of the class.Opening Files Using Constructor:

1. Create a file stream object to manage the stream using the appropriate class. That is, the class ofstream is used to create the output stream and the class ifstream to create the input stream.2. Initialize the file object with the desired filename.

For example, the following statement opens a file named “result” for output:

Ofstream outfile(“result”); //output only

This creates outfile as an ofstream object that manages the output stream. Similarly, the following statement declares infile as an ifstream object and attaches it to the file data for reading(input).

Ifstream infile(“data”); //input only

The statement outfile.close() disconnects the file.

Page 26: school automation system

Opening Files Using open():The function open() can be used to open multiple files that use the same stream

object. File-stream-class stream-object;

Sream-object . open(“filename”);

Example: Ofstream outfile;Outfile.open(“data1”);………..outfile.close();outfile.open(“data2”);

The above program segment opens two files in sequence for writing the data. Note that the first file is closed before opening the second one. This is necessary because a stream can be connected to only one file at a time.

Reading and Writing Text Files:

It is very easy to read from or write to a text file. Simply use the << and >> operators the same way you do when performing console I/O, except that instead of using cin and cout, substitute a stream that is linked to a file.

Sequential Input And Output Operations:

The file stream classes support a number of member functions for performing the input and output operations on files. One pair of functions, put() and get() , are designed for handling a single character at a time. Another pair of functions, write() and read(), are designed to write and read blocks of binary data.

Put() and get() functions:

The function put() writes a single character to the associated stream. Similarly, the function get() reads a single character from the associated stream.

Write() and read() functions:

The functions write() and read() , unlike the functions put() and get(), handle the data in binary form. This means that the values are stored in the disk file in the same format in which they are stored in the internal memory.

Inflie. Read((char*)&v, sizeof(v));Outfile.write((char*)&v, sizeof(v));

Page 27: school automation system

These functions take tow arguments. The first is the address of the variable v, and the second is the length of that variable in bytes. The address of the variable must be cast to type char*.

10. Command Line Arguments

* Sometimes it is useful to pass information into a program when you run it. * Generally, you pass information into the main() function via command line arguments.

*A command line argument is the information that follows the program's name on the command line of the operating system. *There are two special built-in arguments, argv and argc, that are used to receive command line arguments. *The argc parameter holds the number of arguments onthe command line and is an integer. *The argv parameter is a pointer to an array ofcharacter pointers. Each element in this array points to a command line argument.

11. Graphical Interfaces: Dialog Boxes

Suppose you don't want to deal with command line interpretation, but you still want your program to be able to change the values of certain variables in an interactive way. You could simply program in a series printf/scanf lines to quiz the user about their preferences:...printf("Please enter the value of n: ");scanf("%d", &n);printf("Please enter the value of x: ");scanf("%f", &x);...and so on, but this won't work well if your program is to be used as part of a pipeline (see the UNIX primer), for example using ther graphics program plot_data, sincethe questions and answers will get mixed up with the data stream. A convenient alternative is to use a simple graphical interface which generates a dialog box, offering you the option of varying key parameters in your program. Our graphics package provides a number of easy -to-use tools for constructing and using such boxes. The simplest way to set the integer variabl e n and the float variable x (i.e. to perform the same effect as the above lines of code) using a dialog box is as follows:

/* Simple program to illustrate use of a dialog box */main(){/* Define default values: */int n = 0;

Page 28: school automation system

float x = 0.0;/* Define contents of dialog window */create_int_dialog_entry("n", &n);create_float_dialog_entry("x", &x);/* Create window with name "Setup" and top -leftcorner at (0,0) */set_up_dialog("Setup", 0, 0);/* Display the window and read the results */read_dialog_window();/* Print out the new values */printf("n = %d, x = %f\n", n, x);}

Compile this program using the alias Cgfx (see the page on compilation) to link in all necessary libraries. The two create lines define the entries in the box and the variables to be associated with them; set_up_dialog names the box and defines its location. Finally, read_dialog_window pops up a window and allows you to change the values of the variables. When the program runs, you will see a box that looks someth ing like this:Modify the numbers shown, click "OK" (or just hit carriage return), and the changes are made. That's all there is to it! The great advantage of this approach is that it operates independently of the flow of data through stdin/stdout. In principle, you could evenControl the operation of every stage in a pipeline of many chained commands, using a separate dialog box for each.

Progam

/* SCHOOL AUTOMATION SYSTEM *//*--------------------------*/ #include<conio.h> #include<stdio.h>

Page 29: school automation system

#include<stdlib.h> #include<graphics.h> #include<string.h> #include<dos.h>

void add_rec (void); void edit_rec (void); void delete_rec (void); void display_all_rec (void); void display_single_rec (void); int Pass (void); //checks for admimnistrator password int check_user(void); //checks for user id and password void splash(void); // front screen void end_splash(void); void administrator(void);// called when logged in as an administrator void user_menu(void); // called when logged in as user void add_user(void); void delete_user(void); void display_user(void);

int initmouse(); void showmouseptr(); int restrictmouseptr(int x1,int y1,int x2,int y2); void getmousepos(int *button,int *x,int *y);

union REGS i,o;

struct user { char username[12],userpswd[12]; }; FILE *usrptr; struct user usrrec;

struct student { int rno; char name[50],clas[50],f_name[50],ph[8],adrs[50],date[15]; char gender; };

student rec; //Global variable of student rec

Page 30: school automation system

FILE *fptr; //Global variable for file int x,y,button; char name[12]; void main(void) {

fptr=fopen("student.dat","rb+");if (fptr==NULL){

fptr=fopen("student.dat","wb+");if (fptr==NULL){

printf("\n Can't create file");getch();exit(1);

} }

if (initmouse()==0){closegraph();restorecrtmode();printf("\nMouse driver not loaded");exit(1);}

usrptr=fopen("userfile.dat","rb+"); if(usrptr==NULL) { usrptr=fopen("userfile.dat","wb+"); if(usrptr==NULL) {

printf("SORRY CANNOT CREATE USER FILE");return;

}// end if }// end if

splash();

int gd=DETECT,gm,errorcode,xc,yc;initgraph(&gd,&gm,"c:\\tc\\bgi");errorcode = graphresult();

if (errorcode != grOk)

Page 31: school automation system

{printf("Graphics error: %s\n",

grapherrormsg(errorcode));printf("Press any key to halt:");getch();exit(1);}

cleardevice(); setbkcolor(1); int menu=13; char op; while(menu==13) { cleardevice(); setcolor(5); showmouseptr(); rectangle(70,55,280,80);gotoxy(10,5); printf("1-->LOGIN AS ADMINISTRATOR"); rectangle(70,90,280,115);gotoxy(10,7); printf("2-->LOGIN AS USER"); rectangle(70,125,280,150);gotoxy(10,9); printf("3-->EXIT");

while(!kbhit()){showmouseptr();getmousepos(&button,&xc,&yc);if (((button & 1)==1)&&(xc>70&&xc<280)&&(yc>55&&yc<80)){

administrator();cleardevice();}if (((button &

1)==1)&&(xc>70&&xc<280)&&(yc>90&&yc<115)){

user_menu();cleardevice();}if (((button &

1)==1)&&(xc>70&&xc<280)&&(yc>125&&yc<150)){

end_splash();cleardevice();exit(0);}

}

Page 32: school automation system

gotoxy(10,11); printf("ENTER YOUR CHOICE <1 TO 3> : "); op=getch(); switch(op) { case '1': administrator(); break; case '2': user_menu(); break; case '3': end_splash(); break; default: printf("Please enter the listed options"); }

}//end while }

void administrator(void) {

char ch;int c=Pass(),xc,yc;if(c==0) return;

int menu=13;while (menu==13)

{cleardevice();for (x=68,y=3;x<=40,y<=31;x--,y++){gotoxy(y,3);printf(" DISPLAY ");gotoxy(x,3);printf(" MAIN MENU ");delay(15);}

setcolor(5); showmouseptr();

rectangle(160,55,400,80);gotoxy(22,5);printf("1-->ADD RECORD");

rectangle(160,90,400,115);gotoxy(22,7);printf("2-->EDIT RECORD");

rectangle(160,120,400,145);gotoxy(22,9);printf("3-->DISPLAY SINGLE RECORD");

rectangle(160,155,400,180);gotoxy(22,11);printf("4-->DISPLAY ALL RECORDS");

rectangle(160,185,400,210);gotoxy(22,13);printf("5-->DELETE RECORD");

Page 33: school automation system

rectangle(160,215,400,240);gotoxy(22,15);printf("6-->ADD USER");

rectangle(160,245,400,280);gotoxy(22,17);printf("7-->DISPLAY ALL USERS");

rectangle(160,285,400,310);gotoxy(22,19);printf("8-->DELETE USER");

rectangle(160,315,400,345);gotoxy(22,21);printf("9-->LOG OFF ADMINISTRATOR");

gotoxy(22,23);printf(" Enter your Choice <1 TO 9> : ");

while (!kbhit()) { showmouseptr(); getmousepos(&button,&xc,&yc); if (((button &

1)==1)&&(xc>160&&xc<400)&&(yc>55&&yc<80)) { add_rec();break; } if (((button &

1)==1)&&(xc>160&&xc<400)&&(yc>90&&yc<115)) { edit_rec();break; } if (((button &

1)==1)&&(xc>160&&xc<400)&&(yc>120&&yc<145)) { display_single_rec();break; } if (((button &

1)==1)&&(xc>160&&xc<400)&&(yc>155&&yc<180)) { display_all_rec();break; } if (((button &

1)==1)&&(xc>160&&xc<400)&&(yc>185&&yc<210)) { delete_rec();break; } if (((button &

1)==1)&&(xc>160&&xc<400)&&(yc>215&&yc<240)) { add_user();break; } if (((button &

1)==1)&&(xc>160&&xc<400)&&(yc>245&&yc<280)) {

Page 34: school automation system

display_user();break; } if (((button &

1)==1)&&(xc>160&&xc<400)&&(yc>285&&yc<310)) { delete_user();break; }

if (((button & 1)==1)&&(xc>160&&xc<400)&&(yc>315&&yc<345)) { return; }

} ch=getch(); getche(); switch(ch) {

case '1':add_rec(); break;case '2':edit_rec(); break;case '3':display_single_rec(); break;case '4':display_all_rec(); break;case '5':delete_rec(); break;case '6':add_user(); break;case '7':display_user(); break;case '8':delete_user(); break;case '9':return;

} // end switches

}// end while

}// end body of administrator

void add_rec(void) //user define function {

char t[5],ch;cleardevice();

for (x=68,y=3;x<=38,y<=31;x--,y++){gotoxy(y,3);printf(" DISPLAY ");gotoxy(x,3);printf(" Add RECORD MENU ");

Page 35: school automation system

delay(15);}

char srec;rewind (fptr);

gotoxy(10,5); printf("ENTER G.R.NO. > "); gets(t);

srec=atoi(t);

while (fread(&rec,sizeof(rec),1,fptr)==1);{ if (srec==rec.rno) { gotoxy(5,23);printf("Sorry! This Record Already

Exist"); gotoxy(5,24);printf("PRESS ANY KEY TO CONTINUE"); getch(); return; }// end if}// end whilerec.rno=atoi(t);gotoxy(10,7); printf("ENTER NAME

> ");gets(rec.name);gotoxy(10,9); printf("ENTER FATHER'S NAME

> ");gets(rec.f_name);gotoxy(10,11);printf("ENTER GENDER(M/F)

> ");rec.gender=getche();if ((rec.gender=='M'||rec.gender=='m')||

(rec.gender=='F'||rec.gender=='f'))printf("%c",rec.gender);scanf("%c",&ch);

gotoxy(10,13);printf("ENTER CLASS > ");

gets(rec.clas);gotoxy(10,15);printf("ENTER ADDRESS

> ");gets(rec.adrs);gotoxy(10,17);printf("ENTER PHONE #

> ");gets(rec.ph);gotoxy(10,19);printf("ENTER DATE OF

ADMISSION(DD/MM/YY)> ");gets(rec.date);

Page 36: school automation system

gotoxy(15,21);printf("Do You Want To Save This Record (Y/N) : ");

ch=getch();if(ch=='Y' || ch=='y'){

fwrite(&rec,sizeof(rec),1,fptr);gotoxy(15,23);printf("RECORD SAVED ");gotoxy(15,24);printf("PRESS ANY KEY TO CONTINUE");getch();cleardevice();

}

}

void edit_rec(void) { int Erec=0, found=0; char t[50],ch,ch1; long int s; cleardevice(); for(x=60,y=3;x>=40,y<=25;x--,y++) { cleardevice(); gotoxy(y,2); printf("DISPLAY EDIT"); gotoxy(x,2); printf("RECORD MENU"); delay(50); }// end for loop gotoxy(10,5); printf("ENTER G.R.NO. FOR EDITING : "); gets(t); Erec=atoi(t); Ag3:

{rewind(fptr);

while(fread(&rec,sizeof(rec),1,fptr)==1) { if(rec.rno==Erec) { cleardevice(); found=1; for(x=60,y=3;x>=40,y<=25;x--,y++) {

cleardevice(); gotoxy(y,2); printf("DISPLAY EDIT"); gotoxy(x,2); printf("RECORD MENU"); delay(50);

}// end for loop

Page 37: school automation system

gotoxy(10,5); printf("G.R.NO. : %d",rec.rno);

gotoxy(10,6); printf("NAME : %s ",rec.name);

gotoxy(10,7); printf("FATHER'S NAME : %s",rec.f_name);

gotoxy(10,8); printf("CLASS : %s",rec.clas);

gotoxy(50,8); printf("GENDER : %c",rec.gender);

gotoxy(10,9); printf("RESIDENTIAL ADDRESS : %s",rec.adrs);

gotoxy(10,10); printf("PHONE : %s",rec.ph);

gotoxy(10,11); printf("DATE OF ADMISSION : %s",rec.date);

gotoxy(15,13); printf("EDIT THIS RECORD CHOOSE (1 TO 9) : ");

gotoxy(15,15);printf("1->ENTER NEW G.R.NO.");gotoxy(15,16);printf("2->ENTER NEW NAME");gotoxy(15,17);printf("3->ENTER NEW FATHER'S

NAME");gotoxy(15,18);printf("4->ENTER NEW CLASS");gotoxy(15,19);printf("5->ENTER NEW GENDER");gotoxy(15,20);printf("6->ENTER NEW RESIDENTIAL

ADDRESS");gotoxy(15,21);printf("7->ENTER NEW PHONE");gotoxy(15,22);printf("8->ENTER NEW DATE OF

ADMISSION");gotoxy(15,23);printf("9->EXIT TO EDIT MENU");

ch=getch(); switch(ch)

{case '1':

char temp[4];char ser;rewind (fptr);gotoxy(10,25);printf("Enter New

G.R.No. : ");gets(temp);ser=atoi(temp);while

(fread(&rec,sizeof(rec),1,fptr)==1);{ if (ser==rec.rno) {

Page 38: school automation system

gotoxy(15,27);printf("Sorry! This G.R.No Already Exist. Delete First...");

gotoxy(15,28);printf("PRESS ANY KEY TO CONTINUE....");

getch(); return;

}// end if}// end whilerec.rno=atoi(temp);s=sizeof(rec); //finding the size of

recfseek(fptr,-s,SEEK_CUR); //setting

pointer in file1fwrite(&rec,sizeof(rec),1,fptr);gotoxy(15,26);printf("RECORD SAVED");gotoxy(15,27);printf("PRESS ANY KEY TO CONTINUE");getch();goto Ag3;break;

case '2':gotoxy(10,25);printf("Enter New Name :

");gets(rec.name);s=sizeof(rec); //finding the size of

recfseek(fptr,-s,SEEK_CUR); //setting

pointer in file1fwrite(&rec,sizeof(rec),1,fptr);gotoxy(15,27);printf("RECORD SAVED");gotoxy(15,28);printf("PRESS ANY KEY TO CONTINUE");getch();goto Ag3;break;

case '3':gotoxy(10,25);printf("Enter New Father's

Name : ");gets(rec.f_name);s=sizeof(rec); //finding the size of

recfseek(fptr,-s,SEEK_CUR); //setting

pointer in file1fwrite(&rec,sizeof(rec),1,fptr);gotoxy(15,27);

Page 39: school automation system

printf("RECORD SAVED");gotoxy(15,28);printf("PRESS ANY KEY TO CONTINUE");getch();goto Ag3;break;

case '4':gotoxy(10,25);printf("Enter New Class :

");gets(rec.clas);s=sizeof(rec); //finding the size of

recfseek(fptr,-s,SEEK_CUR); //setting

pointer in file1fwrite(&rec,sizeof(rec),1,fptr);gotoxy(15,27);printf("RECORD SAVED");gotoxy(15,28);printf("PRESS ANY KEY TO CONTINUE");getch();goto Ag3;break;

case '5':gotoxy(10,25);printf("Enter New Gender :

");rec.gender=getche();if ((rec.gender=='M'||rec.gender=='m')||

(rec.gender=='F'||rec.gender=='f'))printf("%c",rec.gender);scanf("%c",&ch1);s=sizeof(rec); //finding the size of

recfseek(fptr,-s,SEEK_CUR); //setting

pointer in file1fwrite(&rec,sizeof(rec),1,fptr);gotoxy(15,27);printf("RECORD SAVED");gotoxy(15,28);printf("PRESS ANY KEY TO CONTINUE");getch();goto Ag3;break;

case '6':gotoxy(10,25);printf("Enter New

Residential Address : ");gets(rec.adrs);

Page 40: school automation system

s=sizeof(rec); //finding the size of rec

fseek(fptr,-s,SEEK_CUR); //setting pointer in file1

fwrite(&rec,sizeof(rec),1,fptr);gotoxy(15,27);printf("RECORD SAVED");gotoxy(15,28);printf("PRESS ANY KEY TO CONTINUE");getch();goto Ag3;break;

case '7':gotoxy(10,25);printf("Enter New Phone :

");gets(rec.ph);s=sizeof(rec); //finding the size of

recfseek(fptr,-s,SEEK_CUR); //setting

pointer in file1fwrite(&rec,sizeof(rec),1,fptr);gotoxy(15,27);printf("RECORD SAVED");gotoxy(15,28);printf("PRESS ANY KEY TO CONTINUE");getch();goto Ag3;break;

case '8':gotoxy(10,25);printf("Enter New Date of

Addmission : ");gets(rec.date);s=sizeof(rec); //finding the size of

recfseek(fptr,-s,SEEK_CUR); //setting

pointer in file1fwrite(&rec,sizeof(rec),1,fptr);gotoxy(15,27);printf("RECORD SAVED");gotoxy(15,28);printf("PRESS ANY KEY TO CONTINUE");getch();goto Ag3;break;

case '9':return;

}

Page 41: school automation system

}}}

if(found==0) { gotoxy(15,21); printf("NO RECORD FOUND"); gotoxy(15,22); printf("PRESS ANY KEY TO CONTINUE"); getch(); } }//end body of edit user

void display_single_rec(void) { int srec=0,found=0; char t[5]; cleardevice();

for (x=60,y=3;x<=30,y<=31;x--,y++){gotoxy(y,3);printf(" DISPLAY ");gotoxy(x,3);printf(" SINGLE RECORD MENU ");delay(15);}

gotoxy(20,6);printf("ENTER G.R.NO. FOR SEARCHING > "); gets(t);srec=atoi(t); rewind(fptr);

while (fread(&rec,sizeof(rec),1,fptr)==1) {

if (rec.rno==srec){

cleardevice();for (x=60,y=3;x<=30,y<=31;x--,y++){gotoxy(y,3);printf(" DISPLAY ");gotoxy(x,3);printf(" SINGLE RECORD MENU ");delay(15);}found=1;gotoxy(10,7); printf("NAME : %s ",rec.name);gotoxy(50,7); printf("G.R.NO. : %d",rec.rno);

Page 42: school automation system

gotoxy(10,9); printf("FATHER'S NAME : %s",rec.f_name);

gotoxy(10,11);printf("CLASS : %s",rec.clas);gotoxy(50,11);printf("GENDER : %c",rec.gender);gotoxy(10,13);printf("RESIDENTIAL ADDRESS :

%s",rec.adrs);gotoxy(10,15);printf("PHONE : %s",rec.ph);gotoxy(10,17);printf("DATE OF ADMISSION :

%s",rec.date);

gotoxy(17,22);printf("PREES ANY KEY TO CONTINUE");getch();cleardevice();

}

} if (found==0) {

gotoxy(15,22);printf("RECORD NOT FOUND");gotoxy(15,23);printf("PRESS ANY KEY TO CONTINUE");getch();cleardevice();

}

}

void display_all_rec(void) { rewind(fptr); while(fread(&rec,sizeof(rec),1,fptr)==1) { cleardevice();

for (x=68,y=3;x<=38,y<=31;x--,y++){ gotoxy(y,3);printf(" DISPLAY "); gotoxy(x,3);printf(" All RECORD MENU "); delay(15);}

gotoxy(10,7);printf ("NAME : %s ",rec.name);gotoxy(50,7);printf ("G.R.NO. : %d",rec.rno);gotoxy(10,9);printf("FATHER'S NAME : %s",rec.f_name);gotoxy(10,11);printf("CLASS : %s",rec.clas);gotoxy(50,11);printf("GENDER : %c",rec.gender);gotoxy(10,13);printf("RESIDENTIAL ADDRESS :

%s",rec.adrs);

Page 43: school automation system

gotoxy(10,15);printf("PHONE : %s",rec.ph);gotoxy(10,17);printf("DATE OF ADMISSION :

%s",rec.date);gotoxy(17,22);printf("PREES ANY KEY TO CONTINUE");getch();

} //END WHILE

}// END BODY OF DISPLAY ALL RECORDS

void delete_rec(void) { cleardevice(); int DRec=0,a,found=0; char t[50],ch; FILE *temp; temp=fopen("temp.dat","wb+");

if (temp==NULL){printf("\n Can't create File ");getch();exit(1);}

cleardevice();for (x=68,y=3;x<=38,y<=31;x--,y++){ gotoxy(y,3);printf(" DISPLAY "); gotoxy(x,3);printf(" DEL RECORD MENU "); delay(15);}

gotoxy(5,5);printf("Enter Roll No For Deletion....>=");gets(t);DRec=atoi(t);rewind(fptr);

while(fread(&rec,sizeof(rec),1,fptr)==1) { if (rec.rno==DRec) //checking equality {cleardevice();

for (x=68,y=3;x<=38,y<=31;x--,y++){gotoxy(y,3);printf(" DISPLAY ");gotoxy(x,3);printf(" DEL RECORD MENU ");delay(15);}

Page 44: school automation system

found=1;gotoxy(10,7);printf ("NAME : %s ",rec.name);gotoxy(50,7);printf ("G.R.NO. : %d",rec.rno);gotoxy(10,9);printf("FATHER'S NAME : %s",rec.f_name);gotoxy(10,11);printf("CLASS : %s",rec.clas);gotoxy(50,11);printf("GENDER : %c",rec.gender);gotoxy(10,13);printf("RESIDENTIAL ADDRESS :

%s",rec.adrs);gotoxy(10,15);printf("PHONE : %s",rec.ph);gotoxy(10,17);printf("DATE OF ADMISSION :

%s",rec.date);}else{fwrite(&rec,sizeof(rec),1,temp);}}

if (found==0) { gotoxy(50,22);printf("SORRY NO RECORD FOUNFD"); gotoxy(50,23);printf("Press Any Key to Continue"); getch(); cleardevice(); } else { gotoxy(15,23);printf("DO U WANT TO DELETE THIS RECORD.....Y/N"); ch=getche(); if (ch=='y' || ch=='Y') { fcloseall(); //Closing All Files remove("student.dat"); rename("temp.dat","student.dat"); fptr=fopen("student.dat","rb+"); //Again opening Files if (fptr==NULL) { fptr=fopen("student.dat","wb+"); if (fptr==NULL) { printf("\n cant create file"); getch(); } }

Page 45: school automation system

} }}

int Pass (void) //user define Function { int c=1; //return variable char p[1],res[7]={'\r'}; cleardevice(); gotoxy(28,12);printf("Enter Your Password....>="); for (int a=0;(p[0]=getch())!='\r';a++) { if (p[0]!=8) { setcolor(15); res[a]=p[0]; outtextxy(420+(a*10),180,"*"); } else while (p[0]==8) { setcolor(1); a--; if (a<0)break; outtextxy(420+(a*10),180,"Û"); if (p[0]!=8)break; } } if ((strcmp(res,"admin"))==0) { cleardevice(); int x; gotoxy(17,10); printf("PLEASE WAIT FOR A WHILE!! LOADING IS IN PROGRESS..."); for(x=15;x<60;x++) { gotoxy(x,14);printf("Û"); delay(50);

Page 46: school automation system

} } else { gotoxy(28,14);printf("INCORRECT PASSWORD"); gotoxy(28,15);printf("PRESS ANY KEY TO CONTINUE"); getch(); c=0; return(c); } return(c); }

void splash(void) {

int driver=DETECT,mode; //initialize graphics initgraph(&driver,&mode,"c:\\tc\\bgi"); setbkcolor(1);

settextstyle(1,0,7); outtextxy(200,60,"SCHOOL"); outtextxy(120,160,"AUTOMATION"); outtextxy(200,260,"SYSTEM"); delay(5555); closegraph(); }void user_menu(void) { cleardevice(); int check=check_user(); //variable check confirms the existance of user if(check!=0) { gotoxy(25,14); printf("INVALID USER"); gotoxy(25,16); printf("PRESS ANY KEY TO CONTINUE"); getch(); return; } int menu=13; while(menu==13) { cleardevice(); rewind(fptr); char op; gotoxy(17,2); printf("USER MENU");

Page 47: school automation system

gotoxy(17,3); printf("---------"); gotoxy(13,5); printf("1-->DISPLAY SINGLE RECORD"); gotoxy(13,7); printf("2-->DISPLAY ALL RECORDS"); gotoxy(13,9); printf("3-->LOG OFF %s",name); gotoxy(13,11); printf("ENTER YOUR CHOICE <1 TO 3> : "); op=getch(); switch(op) { case '1': display_single_rec(); break; case '2': display_all_rec(); break; case '3': cleardevice(); return; } //end switch cases }//end while}//end body of user_menu

void add_user(void) { cleardevice(); rewind(usrptr); char confirm; gotoxy(25,2); printf("ADD USER"); gotoxy(25,3); printf("--------"); gotoxy(5,5); printf("ENTER USER NAME : "); gets(name); strupr(name); // convert string to upper case char *str=name; while(fread(&usrrec,sizeof(usrrec),1,usrptr)==1) {

char *s1=name,*s2=usrrec.username;int check=strcmp(s1,s2);if (check==0){ gotoxy(5,7); printf("USER ALREADY EXIST"); gotoxy(5,9); printf("PRESS ANY KEY TO CONTINUE"); getch(); cleardevice(); return;}//end if

}//end while

strcpy(usrrec.username, str); gotoxy(5,7); printf("ENTER PASSWORD : "); gets(usrrec.userpswd); gotoxy(5,9); printf("WISH TO SAVE USER (Y/N) : "); confirm=getche();

Page 48: school automation system

if((confirm=='y')||(confirm=='Y')) { fwrite(&usrrec,sizeof(usrrec),1,usrptr); gotoxy(5,11); printf("USER SAVED"); gotoxy(5,13); printf("PRESS ANY KEY TO CONTINUE"); getch(); }//end if cleardevice(); rewind(usrptr); } //end body of adduser

void display_user(void) { rewind(usrptr); cleardevice(); gotoxy(25,2); printf("DISPLAY OF USERS"); gotoxy(25,4); printf("----------------");

while(fread(&usrrec,sizeof(usrrec),1,usrptr)==1) { gotoxy(10,5); printf("USER NAME : %s ",usrrec.username); gotoxy(10,7); printf("PASSWORD : %s ",usrrec.userpswd); gotoxy(10,9); printf("PRESS ANY KEY TO CONTINUE"); getch(); }//end while cleardevice(); rewind(usrptr); }//end body of displayuser

void delete_user(void) { rewind(usrptr); cleardevice(); int a,check,found=1; char confirm; FILE *temp1; temp1=fopen("temp1.dat","wb+"); if (temp1==NULL)

{ printf("\n ERROR IN DELETING THE RECORD"); getch(); return;}

Page 49: school automation system

gotoxy(25,2); printf("DELETE USER"); gotoxy(25,3); printf("-----------"); gotoxy(10,5);printf("ENTER USER NAME FOR DELETION : "); gets(name); strupr(name); rewind(usrptr); char *str=name; while(fread(&usrrec,sizeof(usrrec),1,usrptr)==1) { char *s1=name,*s2=usrrec.username; int check=strcmp(s1,s2); if(check==0) {

gotoxy(10,7); printf("ARE YOU SURE YOU WANT TO DELETE (Y/N) : ");

found=0; } // end if else {

fwrite(&usrrec,sizeof(usrrec),1,temp1); }//end else }//end while

if(found==0) {

confirm = getch(); if((confirm=='y')||(confirm=='Y')) { fcloseall(); //close all files remove("userfile.dat"); rename("temp1.dat","userfile.dat"); gotoxy(10,9); printf("USER DELETED"); gotoxy(10,11); printf("PRESS ANY KEY TO CONTINUE"); usrptr=fopen("userfile.dat","rb+"); getch(); cleardevice(); }//end if

}//end if else {

gotoxy(10,7); printf("NO RECORD FOUND"); gotoxy(10,9); printf("PRESS ANY KEY TO CONTINUE"); fclose(temp1); remove("temp1.dat"); getch(); cleardevice();

}//end else

Page 50: school automation system

rewind(usrptr); }

// end body of deleteuser

int check_user(void) { int i=0,returnvar=1,checkname,checkpswd; gotoxy(25,10); printf("ENTER USER NAME : "); gets(name); strupr(name); gotoxy(25,12); printf("ENTER PASSWORD : "); //gets(pswd);

char ch=NULL; char pswd[12]={'\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0'}; while(ch!='\r')

{ ch=getch(); if(ch!='\r') {printf("*"); pswd[i]=ch;i++; }//end if}//end while

rewind(usrptr); while(fread(&usrrec,sizeof(usrrec),1,usrptr)==1) {

char *s1=name,*s2=pswd,*s3=usrrec.username, *s4=usrrec.userpswd;

checkname=strcmp(s1,s3);checkpswd=strcmp(s2,s4);if((checkname==0) && (checkpswd==0)) {returnvar=0;}

}//end while return(returnvar); }//end body of check_user

void end_splash(void) {

int driver=DETECT,mode; //initialize graphics initgraph(&driver,&mode,"c:\\tc\bgi"); setbkcolor(1);

Page 51: school automation system

setcolor(15); settextstyle(7,0,4); outtextxy(210,130,"DEVELOPED BY:"); settextstyle(7,0,5); outtextxy(270,170,"SR INFO SYSTEMS");

getch(); closegraph(); }int initmouse()

{i.x.ax=0;int86(0x33,&i,&o);return(o.x.ax);}

void showmouseptr(){i.x.ax=1;int86(0x33,&i,&o);}

int restrictmouseptr(int x1,int y1,int x2,int y2){i.x.ax=7;i.x.cx=x1;i.x.dx=x2;int86(0x33,&i,&o);

i.x.ax=8;i.x.cx=y1;i.x.dx=y2;int86(0x33,&i,&o);}

void getmousepos(int *button,int *x,int *y){i.x.ax=3;int86(0x33,&i,&o);*button=o.x.bx;*x=o.x.cx;*y=o.x.dx;}

Page 52: school automation system

SYSTEM TESTING

Testing Methodology

The importance of software testing and its implications with respect to

software quality cannot be over emphasized. Software testing is a crucial

element of software quality assurance and represents the ultimate review of

specification, design and coding.

The increasing visibility of software as a system element and the

attendant “costs” associated with a software failure are motivating forces for

Page 53: school automation system

well-planned, thorough testing. It is not unusual for a software development

organization to expend 40 percent of total project effort on testing.

Testing is a process of executing a program with the intent of finding

an error. A good test case is the one that has a high probability of finding an

as yet undiscovered error. If testing is conducted successfully (according to

the objective stated), it will uncover errors in the software. As a secondary

benefit, testing demonstrates that software functions appear to be working

according to specification, that performance requirements appear to have

been met. In addition, data collected as testing is conducted provide a good

indication of software reliability and some indication of software quality as a

whole.

UNIT TESTING

Unit testing focuses on verification effort of the smallest unit of

software design - the module. Using the detail design description as a Guide,

important control paths are tested to uncover errors within the boundary of

the module. The module interface is tested to ensure that information

properly follows into and out of the program under test. The database is

examined to ensure that data stored maintains its integrity during all steps in

an algorithm’s execution. Boundary conditions are tested to ensure that all

modules operate properly at boundaries established to limit execution or

exercised to ensure that all statements in the module have been executed at

least once. And finally all error- handling paths are tested. The

unit testing we have used is white-box oriented and for some modules

the steps are conducted in parallel

Page 54: school automation system

WHITE BOX TESTING

White Box Testing ensures that

All independent paths have been exercised at least once

All logical decisions have been exercised on their true and false sides

All loops are executed at their boundaries and within their operational

bounds

All internal data structures have been exercised to assure their validity

To follow the concept of white box testing we have tested each form

we have created independently to verify that

Data flow is correct

All conditions are exercised to check their validity

All loops are executed on their boundaries

Test Cases were designed such that all the paths of the program have been

exercised and tested to check for their validity and correct functionality.

CONDITIONAL TESTING

In this part of the testing each of the conditions were tested to both

true and false aspects. All the resulting paths were tested so that each path on

particular condition is traced to uncover any possible errors.

LOOP TESTING

In this type of testing all the loops are tested to all the limits possible.

All the loops were tested specially at their boundaries, that is, lower and

upper limit. All the loops were skipped at least once. In nested loops the

inner most loops were tested first working outwards.

INTEGRATION TESTING

Page 55: school automation system

Integration testing is a systematic technique for constructing the

program structure while conducting tests to uncover errors associated with

interfacing

INTEGRATION APPROACHWe have used combined approach for integrating different part of

software. the Top-Down strategy have been used for upper level modules and Bottom-Up strategy have been used for sub-ordinate levels

ExampleLogin and homepage module was integrated first in Top-Down

strategy manner. Then the new entry module was created, and this newly

created module after thorough testing was integrated to the system. As new

modules were created, they were added slowly and steadily to the system.

Each time a thoroughly tested module was added to the system, the

regression testing was performed to confirm that newly added module has

not created any unwanted changes

GUI TESTING

GUI testing is done to ensure uniform look and feel of the user

interface components across the application. All the major elements of the

graphical interface such as Window’s, mouse operations etc were validated

during GUI testing. For GUI testing, various selections or options were

made through mouse as well as keyboard to ensure that it works both ways.

It was tested that appropriate messages appear to guide the user through the

course of action.

VALIDATION TESTING

Validation testing succeds when software functions in a manner

that can be resonably expected by the customer. Software validaion is

Page 56: school automation system

achieved through a series of Black-Box tests that demonstrate confirmity

with the requirements. These tests are conducted to ensure that All

functional requirements are satisfied. All performance requirements are

achieved

BLACK BOX TESTING

Black-Box testing focuses on the functional requirements of the

software. Black-box testing Was used while integrating various parts of the

module as a validation testing tool.

Black-Box testing helps to find errors such as

Incorrect or missing functions

Interface errors

Errors in data structures

Performane errors

Initialization and termination errors

PERFORMANCE AND ACCEPTANCE TESTINGA few perspective users of the software were called and the system

was tested in consultation with the users as per the user requirements. To ensure that the software performs as intended by the user, such test data was used that ensures that the results were as intended by the user. Performance testing is designed to test the runtime performance of software within the context of an integrated system. For true performance testing all system elements should be fully integrated.

SYSTEM TESTING

System testing is actually a series of different tests whose primary

purpose is to fully exercise the computer- based systems as a whole.

Although each test has a different purpose, all work should verify that

system elements have been properly integrated and performs allocated

Page 57: school automation system

functions. The aim of system testing is to ensure that the system as a whole

gives intended results.

System Testing also includes Safety testing which attempts to verify

that protection mechanisms built into a system will, in fact, protect it from

improper penetration.

CONCLUSION CONCLUSION

It has been a great pleasure for me to work on this exciting project.

This project proved good for me as it provided practical knowledge of not

only programming in C++ Windows Application, but also about all handling

procedure related with “School Automation System”. It also provides

knowledge about the latest technology used in developing windows enabled

application and client server technology that will be great demand in future.

This will provide better opportunities and guidance in future in developing

projects independently. The project has been appreciated by all the users in

the organization. It is easy to use and User friendly screens are provided. It

has been thoroughly tested and implemented.

Page 58: school automation system

The quality of any project is measured through the Merits and the

Limitations of the project, which it is offering to the user.

MERITS OF THE PROJECT

This project has the following advantages, which are a boon for the

user both in capabilities and validity.

The project offers user to enter the data through simple & informative

forms. This is very helpful for the client to enter the desired

information with so much of simplicity.

There are checks in the every stage of data entry so that the user

cannot enter the invalid data, which will cause problem in future.

Sometimes the user find in the later stages of using the project that he

needs to update some of the information being entered previously.

There are options by which he can update the records. Also primary

field data cannot be changed. This keeps the validity of the data to the

longer extent.

User is provided with the options of monitoring the records he entered

earlier. The desired records can be seen with the variety of options.

From every part of the project user is provided with the links through

framing so that he can go from one option of the project to other one

as per desired

Data storage and retrieval will become faster and easier to maintain

because data is stored in a systematic manner.

Updating of data is easier.

Increases efficiency.

Since computers would be networked together, information can travel

from person to person very quickly.

Page 59: school automation system

LIMITATIONS OF THE PROJECT

As nothing is perfect in this world, we also not claim that our software is perfect. As all other, our project also has some limitations. Those limitations are as follows –

The user has not provided any option to delete any record, which he

has entered once.

Due to the requirements of the user of the data of not only of current

year but also of last few years, the size of the database becomes too

bulky. Due to which the processing speed of any request from the

client becomes a little bit slow.

FUTURE EXTENTION

As the system is scalable, more modules can be added as and when required

The database that is used in the system can be connected to the any business organization.

The system contents can be modified to accept new attributes for any criterion.

Use the same data base in networking. Equip it with reliable and efficient encryption algorithm. Upgrade it with more options and features.