0% found this document useful (0 votes)
59 views17 pages

Database Management Using C+

The document describes a database management system created using C++. It has the following key points: 1) The objective is to create a graphical user interface for simple database management using arrow keys for navigation and hotkeys like N, D, and M for insertion, deletion, and modification of records. 2) The source code uses structures to define a record with fields for code, name, quantity, and cost. It implements functions for display, listing, adding, deleting, and modifying records. 3) The screenshots show the GUI interface with options to add, delete, modify records and navigate between records using arrow keys.

Uploaded by

megadeath_844
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views17 pages

Database Management Using C+

The document describes a database management system created using C++. It has the following key points: 1) The objective is to create a graphical user interface for simple database management using arrow keys for navigation and hotkeys like N, D, and M for insertion, deletion, and modification of records. 2) The source code uses structures to define a record with fields for code, name, quantity, and cost. It implements functions for display, listing, adding, deleting, and modifying records. 3) The screenshots show the GUI interface with options to add, delete, modify records and navigate between records using arrow keys.

Uploaded by

megadeath_844
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 17

DATABASE

MANAGEMENT
using
C+
CONTENTS

 Database management system-


Overview
 Objective
 Source Code
 Screenshot
Database Management system-0verview

A Database Management System (DBMS) is a set of computer programs that


controls the creation, maintenance, and the use of a database. It allows
organizations to place control of database development in the hands
of database administrators (DBAs) and other specialists. A DBMS is a system
software package that helps the use of integrated collection of data records
and files known as databases. It allows different user application programs to
easily access the same database. DBMSs may use any of a variety of database
models, such as the network model or relational model. In large systems, a
DBMS allows users and other software to store and retrieve data in
a structured way. Instead of having to write computer programs to extract
information, user can ask simple questions in a query language. Thus, many
DBMS packages provide Fourth-generation programming language (4GLs) and
other application development features. It helps to specify the logical
organization for a database and access and use the information within a
database. It provides facilities for controlling data access, enforcing data
integrity, managing concurrency, and restoring the database from backups. A
DBMS also provides the ability to logically present database information to
users.
OBJECTIVE

THE AIM OF THIS PROGRAM IS TO MAKE A GUI


FOR SIMPLE DATABASE MANAGEMENT MAKING
IT EASY BY USING ARROW KEYS FOR
NAVIGATING UP&DOWN AND WITH HOT KEYS
(N,D,M) INSERTION,DELETION AND
MODIFICATION OF RECORDS (ITEMS) IS MADE
EASY
COMPILED USING TURBOC 3.0
SOURCE CODE

#include<stdio.h>

#include<conio.h>

#include<string.h>

#include<stdlib.h>

#include<dos.h>

#include<c:\database\vdu.h>

#define datafile "c:\\database\\data.dat"

#define tempfile "c:\\database\\temp.dat"

struct rec

int code;

char name[20]; //structure of a file record used to store in data.dat file

int q;

float cost;

}r;

void display(),list(int*),addn(),dele(int),modify(int);

int count=1,nor=0,count1=0,pagecount=1;

void main()

char ch;

clr(); //clears the screen

while(1)
{

display(); //to create gui

list(&count); // highlight the item count

fflush(stdin);

ch=getch();

if(ch==0)

fflush(stdin);

ch=getch(); //to get scan codes of arrow keys

switch(ch)

case 27: exit(1); // ascii code for escape key

break;

case 'n': addn(); //add new items

// nor++;

break;

case 'd': //delete the item

if((nor>18)&&(count%18==1)&&(count!=1))

pagecount--; //page utility for scrolling

clr();

}
dele(count);

nor--;

count--; //correcting position

if(count<1)

count=1;

clr();

break;

case 'm': modify(count);

clr();

break;

case 72: //up arrow key

if((nor>18)&&(count%18==1)&&(count!=1))

pagecount--;

clr();

if((nor>18)&&(count==1))

else

count--;

if((count<1)&&(nor<=18))

count=nor;

break;

case 80: //down arrow key


if((nor>18)&&(count%18==0))

pagecount++;

clr();

if((pagecount>1)&&(count==nor))

else

count++;

if((count>nor)&&(nor<=18))

count=1;

break;

void display()

int i,k[5]={2,8,18,27,13},j=0;

char q[5][25];

_setcursortype(_NOCURSOR);

sbox(1,1,80,24);
textcolor(15);

textbackground(5);

gotoxy(18,2);

cprintf(" Store Details ");

sline1(1,3,80,3);

strcpy(q[0]," Sno ");

strcpy(q[1]," Item Code ");

strcpy(q[2]," Item Description ");

strcpy(q[3]," Quantity ");

strcpy(q[4]," Price/unit ");

for(i=0;i<5;i++)

j=j+k[i];

gotoxy(j,4);

textcolor(15);

textbackground(6);

cprintf("%s",q[i]);

sline1(1,5,80,5);

sline1(8,3,8,24);

plus(8,5);

sline1(26,3,26,24);

plus(26,5);

sline1(53,3,53,24);

plus(53,5);

sline1(66,3,66,24);
plus(66,5);

textcolor(15);

textbackground(6);

gotoxy(1,25);

cprintf(" ");

gotoxy(1,25);

textcolor(2);

cprintf(" N ");

textcolor(15);

cprintf("Add New Records");

gotoxy(20,25);

textcolor(2);

cprintf(" D ");

textcolor(15);

cprintf("Delete Record");

gotoxy(37,25);

textcolor(2);

cprintf(" R ");

textcolor(15);

cprintf("Return To Main Menu");

textcolor(2);

cprintf(" M ");

textcolor(15);

cprintf("Modify Record");

}
void list(int *c)

int j[5]={2,8,19,27,12},i=0,rp=0,m=0,rc=0;

FILE *fp;

long int recsize;

recsize=sizeof(r);

count1++;

fp=fopen(datafile,"rb+");

if(fp==NULL)

clr();

gotoxy(3,5);

printf("\nFile Creation Error\n\nPlease verify and set the path of ur data.dat file\nif the file does not
exist,create a dummy file as data.dat keep it in the \npath specified above or u can change the path
in the #define statement\nif u know where the file exists\nPress ESC to exit.");

rewind(fp);

while(fread(&r,recsize,1,fp)==1)

i=0;

m=0;

if(count1==1)

nor++; //no.of records

rp++; //record pointer


if((rp>18*(pagecount-1))&&(rp<=18*(pagecount))) //this formula will print the
required records

rc++;

if(rp==(*c))

textcolor(15);

textbackground(10);

else

textcolor(15);

textbackground(0);

m=m+j[i];

gotoxy(m,rc+5);

cprintf("%d.",rp);

i++;

m=m+j[i];

gotoxy(m,rc+5);

cprintf("%d",r.code);

i++;

m=m+j[i];

gotoxy(m,rc+5);

cprintf("%s",r.name);

i++;

m=m+j[i];

gotoxy(m,rc+5);
cprintf("%d",r.q);

i++;

m=m+j[i];

gotoxy(m,rc+5);

cprintf("%.2f",r.cost);

fcloseall();

void addn()

FILE *fp;

struct rec r;

long int recsize;

char vh='y';

fp=fopen(datafile,"rb+");

fseek(fp,0,SEEK_END);

recsize=sizeof(r);

while(vh=='y'||vh=='Y')
{

clr();

_setcursortype(_NORMALCURSOR);

printf("\nEnter the Item Code : ");

scanf("%d",&r.code);

printf("\nEnter the Item Name : ");

scanf("%s",r.name);

printf("\nEnter the Quantity : ");

scanf("%d",&r.q);

printf("\nEnter the Item Cost : ");

scanf("%f",&r.cost);

fwrite(&r,recsize,1,fp);

nor++;

printf("\nPress y to Add One More Record :");

fflush(stdin);

vh=getch();

fcloseall();

clr();

void dele(int count)

FILE *fp,*ft;

struct rec r;
long int recsize;

int k=0;

recsize=sizeof(r);

fp=fopen(datafile,"rb+");

ft=fopen(tempfile,"wb+");

rewind(fp);

while(fread(&r,recsize,1,fp)==1)

k++;

if(k!=count)

fwrite(&r,recsize,1,ft);

fclose(fp);

fclose(ft);

remove(datafile);

rename(tempfile,datafile);

void modify(int count)

FILE *fp;

long int recsize;

int k=0;

struct rec r;

recsize=sizeof(r);

fp=fopen(datafile,"rb+");
_setcursortype(_NORMALCURSOR);

rewind(fp);

while(fread(&r,recsize,1,fp)==1)

k++;

if(k==count)

clr();

printf("\nEnter the NEW Details:\n");

printf("\nEnter the Item Code : ");

scanf("%d",&r.code);

printf("\nEnter the Item Name : ");

scanf("%s",r.name);

printf("\nEnter the Quantity : ");

scanf("%d",&r.q);

printf("\nEnter the Item Cost : ");

scanf("%f",&r.cost);

fseek(fp,-recsize,SEEK_CUR);

fwrite(&r,recsize,1,fp);

fcloseall(); //closing all the files

}
SCREENSHOT

You might also like