Student Record System - Doc Project 2nd Sem
Student Record System - Doc Project 2nd Sem
Student Record System - Doc Project 2nd Sem
such as
add, search, modify, and delete records to manage students� records.
Using this project, you can also generate a mark-sheet for students.*/
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <stdlib.h>
#include <windows.h>
//Structure of student//
struct student{
char ID[15];
char name[20];
char add[20];
char parname[20];
int Class;
long unsigned int phone_no;
};
//creation of student object//
struct student stu;
///This will set the forground color for printing in a console window.
void SetColor(int ForgC)
{
WORD wColor;
///We will need this handle to get the current background attribute
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO csbi;
}
//This funtion is used to clear the window//
void clearWindow(){
int i,j;
for(i = 37; i < 78; i++){
for(j = 7; j < 25; j++){
gotoxy(i,j);printf(" ");
}
}
return;
}
//This function is used to creat a window in the header of the student record//
void window(){
drawRectangle();
gotoxy(32,1);
SetColor(35);
printf("Knowledge 360");
gotoxy(28,2);
SetColor(35);
printf("STUDENT RECORD SYSTEM");
gotoxy(20,3);
printf("College of IT and Management Education, BBSR");
gotoxy(31,4);
printf("Estd: 2000");
gotoxy(25,24);
SetColor(17);
void use_pass_field(){
int x = 15, y = 16;
int use;
char pass[10];
SetColor(10);
gotoxy(15,12);printf("The database is password protected.");
gotoxy(15,13);printf("Enter Valid username and password");
SetColor(17);
gotoxy(20,x);printf("USERNAME:- ");
gotoxy(20,y);printf("PASSWORD:- ");
gotoxy(34,x);scanf("%d",use);
gotoxy(34,y);get_password(pass);
}
////This function is used to Heading of the student record//
void print_heading(const char st[]){
SetColorAndBackground(31,28);
gotoxy(45,8);printf("SRS : %s",st);
SetColorAndBackground(17,15);
}
}else{
fflush(stdin);
gotoxy(print,10);printf("ID: ");gets(stu.ID);
//here you can confirms the ID
gotoxy(print,12);printf("Name: ");gets(stu.name);
gotoxy(print,14);printf("Address: ");gets(stu.add);
gotoxy(print,16);printf("Father's Name: ");gets(stu.parname);
gotoxy(print,18);printf("Class: ");scanf("%d",&stu.Class);
gotoxy(print,20);printf("Phone Number: ");scanf("%ld",&stu.phone_no);
fwrite(&stu, sizeof(stu), 1, fp);
gotoxy(40,22); printf("The Record is Added Successfully !!");
}
SetColor(28);
fclose(fp);
return;
}
//This function is used to search the student record//
void search_student(){
clearWindow();
print_heading("Search Record");
SetColor(45);
char s_id[15];
int isFound = 0;
gotoxy(37,10);printf("Enter ID to Search: ");fflush(stdin);
gets(s_id);
FILE *fp;
fp = fopen("record.txt","rb");
while(fread(&stu,sizeof(stu),1,fp) == 1){
if(strcmp(s_id,stu.ID) == 0){
isFound = 1;
break;
}
}
if(isFound == 1){
gotoxy(37,12);printf("The Record is Found");
gotoxy(37,14);printf("ID: %s",stu.ID);
gotoxy(37,15);printf("Name: %s",stu.name);
gotoxy(37,16);printf("Address: %s",stu.add);
gotoxy(37,17);printf("Father's Name: %s",stu.parname);
gotoxy(37,18);printf("Class: %d",stu.Class);
gotoxy(37,19);printf("Phone Number: %ld",stu.phone_no);
}else{
gotoxy(37,12);printf("Sory, No Record Found in the Database");
}
SetColor(28);
fclose(fp);
return;
}
//This function is used to modify the student record//
void mod_student(){
clearWindow();
print_heading("Modify Record");
SetColor(45);
char s_id[15];
int isFound = 0, print = 37;
gotoxy(37,10);printf("Enter ID to Modify: ");fflush(stdin);
gets(s_id);
FILE *fp;
fp = fopen("record.txt","rb+");
while(fread(&stu, sizeof(stu),1,fp) == 1){
if(strcmp(s_id, stu.ID) == 0){
fflush(stdin);
gotoxy(print,12);printf("ID: ");gets(stu.ID);
gotoxy(print,13);printf("Name: ");gets(stu.name);
gotoxy(print,14);printf("Address: ");gets(stu.add);
gotoxy(print,15);printf("Father's name: ");gets(stu.parname);
gotoxy(print,16);printf("Class: ");scanf("%d",&stu.Class);
gotoxy(print,17);printf("Phone Number: ");scanf("%ld",&stu.phone_no);
fseek(fp,-sizeof(stu), SEEK_CUR);
fwrite(&stu,sizeof(stu), 1, fp);
isFound = 1;
break;
}
}
if(!isFound){
gotoxy(print, 12);printf("404 !! No Record Found");
}
fclose(fp);
SetColor(28);
return;
}
void gen_marksheet(){
//left for further enhancement
}
//This function is used to delete the student record//
void delete_student(){
clearWindow();
print_heading("Delete Record");
SetColor(45);
char s_id[15];
int isFound = 0, print = 37;
gotoxy(37,10);printf("Enter ID to Delete: ");fflush(stdin);
gets(s_id);
FILE *fp, *temp;
fp = fopen("record.txt","rb");
temp = fopen("temp.txt", "wb");
while(fread(&stu, sizeof(stu),1,fp) == 1){
if(strcmp(s_id, stu.ID) == 0){
fwrite(&stu,sizeof(stu),1,temp);
}
}
fclose(fp);
fclose(temp);
remove("record.txt");
rename("temp.txt","record.txt");
gotoxy(37,12);printf("The record is sucessfully deleted");
SetColor(28);
return;
}
//In this function we can choose an option to interact with the student record//
void main_window(){
int choice;
SetColor(28);
int x = 2;
while(1){
gotoxy(x,8);printf("1. Add Student");
gotoxy(x,10);printf("2. Search Student");
gotoxy(x,12);printf("3. Modify Student Record");
gotoxy(x,14);printf("4. Generate Marksheet // Left");
gotoxy(x,16);printf("5. Delete Student Record");
gotoxy(x,18);printf("6. Change Password // Left");
gotoxy(x,20);printf("7. Exit");
gotoxy(x,22);printf("Enter Your Choice: ");
scanf("%d",&choice);
switch(choice){
case 1:
add_student();
break;
case 2:
search_student();
break;
case 3:
mod_student();
break;
case 4:
break;
case 5:
delete_student();
break;
case 6:
break;
case 7:
exit(0);
break;
default:
break;
}
}
//Main function started//
int main(){
ClearConsoleToColors(17,15);
SetConsoleTitle("Knowledge 360 - Student Record System");
window();
//use_pass_field();
main_window();
return 0;
}//End of Main//