C ++ Program: School Fee Inquiry System in C++ and MySQL

CWC
7 Min Read

A school fee inquiry system is designed using a MySQL database and a simple C ++ program to read the information in the database, calculate the average of the school fees, compare the average with the maximum amount of the fees, and return the result to the user.

In a school fee inquiry system, we should first learn about the MySQL database and C ++ programming language. In this type of application, we should use the SQL command to create a table. Then we should store data into the table. The program must be designed to display the content of the table. It is important that you understand all of these concepts to design an application like this.

C ++ Program: School Fee Inquiry System in C++ and MySQL This program can calculate and store the student tuition fee. It can make the list of the student total fee and with all their information. Users can add students, edit the student record, delete student records and search for students from the database.

Program Description School Fee Inquiry System in C++ and MySQL:

The program has a database connection class call at the beginning of the program. Individual functions for all the different features like add, delete, search, edit and show list of students. The program also have exit method that terminate the program with pop up message. User can also run same function as their need.

Program Detail:

Global variables

  • qstate represent the state of the query. If 0 is successful 1 is failed.
  • conn is the mysql connection variable.
  • row is for getting the current row of the database.
  • res is for getting all the values form the database.

Class db_response

  • This class contains connection of the database.
  • mysql_init is the initializer of mysql_real_connect
  • mysql_real_connect connects to the database. (MySql server should open while connecting)
  • the if statement shows the successful or failed connection.

Function main

  • Here firstly the clear screen command then the title command and the color command.
  • db_response::ConnectionFunction() is create the connection to the database.
  • The program features
    • List of Fees.
    • Add New Student.
    • Search Student Record.
    • Edit Student Record.
    • Delete Student Record.
  • The switch case is used for switching between this functions
    • ListOfFees ();
    • AddNewStudents ();
    • SearchStudentRecord ();
    • EditStudentRecord ();
    • DeleteStudentRecord ();

Function ListOfFees

  • Initially two options are given (Total Fee List, Full Detail Fee List)
  • For the first option user can only see the student name and total fee of the student in a list.
  • The “select s_name, f_total from studentinfo_tb” sql query, used for getting the values from database and print the value from “res” variable using while loop.
  • The “select * from studentinfo_tb” sql query, used for getting the values from database and print the value from “res” variable using while loop.

Function AddNewStudents

  • Here user can add new student record.
  • User can enter the details of the student. Like name, id, class, tuition fee, lab fee, annual fee, activity fee and the program calculate the total fee and add into the database.
  • Tuition fee, lab fee, annual fee, activity fee should be number otherwise the program will get the input again. Isdigit function used for checking, is there any character or number.
  • After the input the program execute the insert_query (A variable holing the insertion query).
  • Then the program show the successful message.
  • Finally Exit Code run for go to menu or repeat the function or exit from the console.

Function SearchStudentRecord

  • User can search any record from the database.
  • The user can search by student name, id, class, total fee more than or equal and total fee less than or equal.
  • The user can find by only one character if the character matches with the respective columns row.
  • Then by the user choice the program show the desired result.
  • Finally Exit Code run for go to menu or repeat the function or exit from the console.

Function EditStudentRecord

  • The program can edit the student record.
  • Firstly the “select * from studentinfo_tb” query execute for getting the student record.
  • Then the user can enter the column id. The input has a number validator.
  • Now the program checks is the record is in the database or not. If not then the program show an item not found pop up message.
  • If the program found the record then the program show the record in the console.
  • After that the user set the new value for the student and if the user don’t want to change any record then the user can use ‘xN’.
  • Finally the ‘’Update” query update the new record as given by the user.
  • And show success pop up message.
  • Finally Exit Code run for go to menu or repeat the function or exit from the console.

Function DeleteStudentRecord

  • The function can delete student record.
  • The “Delete” query used to delete the record from the database.
  • It shows all the records than want the input of the user column id.
  • The input is number validator so the user cannot use any other character except numbers.
  • Then the program checks is the record is in the database or not.
  • If this is in the database than the program delete the record and if not then the program shows not in database message in the console.
  • Finally Exit Code run for go to menu or repeat the function or exit from the console.

Database and Table Name

Table: studentinfo_tb
Database: cpp_schoolfeeinquiry_db

Usage

XAMPP Server, MySql Headers, MySql Libs

Share This Article
Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

English
Exit mobile version