How to create Leave Management System in Visual C++ Programming OOAD

This project on “Leave management system” was developed mainly for checking the leave period &leave balance of a employee. On intent is to create a leave record. We use 3 functions each independent from each other. This function will get the input from the user & the respective leave period &leave balances which are maintained. Database basic insert delete display has been maintained by the basic sql query.
Free Source code in Visual C++ Programming
#include<windows.h>
#include<sqlext.h>
#include<stdio.h>
#include<string.h>
#define TEST_LEN 50
int main()
{
int c;
char ch='y';
SQLINTEGER IDno,Phoneno,Leaveperiod,Leavebal;
SQLCHAR Name[TEST_LEN+1];
HENV hEnv=NULL;
HDBC hDBC=NULL;
HSTMT hStmt=NULL;
UCHAR szSqlStr[]="insert into leave(IDno,Name,Phoneno,Leaveperiod,Leavebal) values(?,?,?,?,?)";
UCHAR szSqlStr1[]="delete * from leave where IDno = ?";
UCHAR szSqlStr2[]="select * from leave";
UCHAR szDSN[SQL_MAX_DSN_LENGTH]="leavemanage";
UCHAR *szUID=NULL;
UCHAR *szPasswd=NULL;
UCHAR szModel1[128];
UCHAR szModel2[128];
UCHAR szModel3[128];
UCHAR szModel4[128];
UCHAR szModel5[128];
SDWORD cbModel1;
SDWORD cbModel2;
SDWORD cbModel3;
SDWORD cbModel4;
SDWORD cbModel5;
SDWORD cbtest=SQL_NTS;
RETCODE retcode;
do
{
printf("=======================================\n LEAVE MANAGEMENT SYSTEM\n=======================================\n");
printf("1.Enter the leave detail \n2.Delete the leave detail\n3.Display the leave detail\n\n");
printf("Enter ur option......\n");
scanf("%d",&c);
switch(c)
{
case 1:
printf("\n-----------------------------------------");
printf("\nEnter the details");
printf("\n-----------------------------------------");
printf("\nEnter the ID No:\t");
scanf("%d",&IDno);
printf("\nEnter the Name:\t");
scanf("%s",&Name);
printf("\nEnter the Phoneno:\t");
scanf("%d",&Phoneno);
printf("\nEnter the Leaveperiod:\t");
scanf("%d",&Leaveperiod);
printf("\nEnter the Leavebal:\t");
scanf("%d",&Leavebal);
printf("\n-----------------------------------------");
SQLAllocEnv(&hEnv);
SQLAllocConnect(hEnv,&hDBC);
retcode=SQLConnect(hDBC,szDSN,SQL_NTS,szUID,SQL_NTS,szPasswd,SQL_NTS);
if(retcode==SQL_SUCCESS||retcode==SQL_SUCCESS_WITH_INFO)
{
retcode=SQLAllocStmt(hDBC,&hStmt);
retcode=SQLPrepare(hStmt,szSqlStr,sizeof(szSqlStr));
SQLBindParameter(hStmt,1,SQL_PARAM_INPUT,SQL_C_LONG,SQL_INTEGER,1,0,&IDno,0,&IDno);
SQLBindParameter(hStmt,2,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,TEST_LEN,0,Name,0,&cbtest);
SQLBindParameter(hStmt,3,SQL_PARAM_INPUT,SQL_C_LONG,SQL_INTEGER,1,0,&Phoneno,0,&Phoneno);
SQLBindParameter(hStmt,4,SQL_PARAM_INPUT,SQL_C_LONG,SQL_INTEGER,1,0,&Leaveperiod,0,&Leaveperiod);
SQLBindParameter(hStmt,5,SQL_PARAM_INPUT,SQL_C_LONG,SQL_INTEGER,1,0,&Leavebal,0,&Leavebal);
retcode=SQLExecute(hStmt);
printf("\n\n Detail is inserted.......... \n\n");
}
break;
case 2:
printf("\nDelete the detail\n");
SQLAllocEnv(&hEnv);
SQLAllocConnect(hEnv,&hDBC);
retcode=SQLConnect(hDBC,szDSN,SQL_NTS,szUID,
SQL_NTS,szPasswd,SQL_NTS);
if(retcode==SQL_SUCCESS||retcode==SQL_SUCCESS_WITH_INFO)
{
retcode=SQLAllocStmt(hDBC,&hStmt);
retcode=SQLPrepare(hStmt,szSqlStr1,sizeof(szSqlStr1));
SQLBindParameter(hStmt,1,SQL_PARAM_INPUT,SQL_C_LONG,SQL_INTEGER,1,0,&IDno,0,&IDno);
printf("\nEnter the ID No\n");
scanf("%d",&IDno);
retcode=SQLExecute(hStmt);
printf("detail has been deleted\n\n");
}
break;
case 3:
printf("\nDisplay the detail\n");
SQLAllocEnv(&hEnv);
SQLAllocConnect(hEnv,&hDBC);
retcode=SQLConnect(hDBC,szDSN,SQL_NTS,szUID,SQL_NTS,szPasswd,SQL_NTS);
if(retcode==SQL_SUCCESS||retcode==SQL_SUCCESS_WITH_INFO)
{
retcode=SQLAllocStmt(hDBC,&hStmt);
retcode=SQLPrepare(hStmt,szSqlStr2,sizeof(szSqlStr2));
retcode=SQLExecute(hStmt);
SQLBindCol(hStmt,1,SQL_C_CHAR,szModel1,sizeof(szModel1),&cbModel1);
SQLBindCol(hStmt,2,SQL_C_CHAR,szModel2,sizeof(szModel2),&cbModel2);
SQLBindCol(hStmt,3,SQL_C_CHAR,szModel3,sizeof(szModel3),&cbModel3);
SQLBindCol(hStmt,4,SQL_C_CHAR,szModel4,sizeof(szModel4),&cbModel4);
SQLBindCol(hStmt,5,SQL_C_CHAR,szModel5,sizeof(szModel5),&cbModel5);
retcode=SQLFetch(hStmt);
printf("\n\tID No\tName\tPhoneno\tLeave Period\tLeave Bal\n\n");
while(retcode==SQL_SUCCESS||retcode==SQL_SUCCESS_WITH_INFO)

{
printf("\t%s\t%s\t%s\t%s\t%s\n",szModel1,szModel2,szModel3,szModel4,szModel5);
retcode=SQLFetch(hStmt);
}
}

break;

}
flushall();
printf("\nDo u wan to cont (y/n)");
scanf("%s",&ch);
}
while(ch=='y');
return 0;
}
Leave management System Output Screen shot in Object Oriented Analysis
Enter the details using basic Sql insert mode
Using Select Sql query display the details

How to delete record from leave management System

Related post