The application is to be designed and implemented within a .Net framework. It wi
ID: 3819794 • Letter: T
Question
The application is to be designed and implemented within a .Net framework. It will be implemented using the 3-tier application architecture that we have discussed in class. The entire application will be developed using Microsoft
Visual Studio 2013 using the Language C#. For the database environment, you will use Microsoft SQL Server.
Phase # 2 Requirements:
In this phase of the project, you will design and implement a Windows project that connects to a local SQL Server database.
1. Database: create the following tables in a local database. After the database tables are created, you must enter sample data for testing your project.
<<>>
Database Table: Employee
Column Name
Data
Type
Comment
EmployeeID
int
identity
Name
nvarchar (30)
PhoneNumber
nvarchar (15)
RoomNumber
nvarchar (10)
PayMonths
int
PaymentMonth
double
2. Code Development. You are required to create a Windows application. The application provides the features that maintain the information on Employees.
The requirements of the application are described as follows:
a. You must create an Employee class, representing data used in your application. Your class will have all the attributes in the table and corresponding constructors.
b. You must create a local database that will be included in your project. (Hint: see our manual)
c. You will create a Dynamic Link Library (dll) named DeptDLL. This dll will calculate the total payment for each employee and show this total in a messagebox when a user clicks on an employee row in the datagridview. After creating the dll make sure you copy it inside your project folder and only after that reference it in your project
d. You will use table adaptors, data source, binding source, buttons and a datagridview to select, insert, update and delete data into your database. Your datagridview will display the data in your table.
e. While the Select button will be displayed from the start of the program, the other buttons (insert, delete, update, and navigation buttons) will be created at runtime (after a user clicks on the Select button). You must zip your answer file from your solution folders that contains all of your project files.
The GUI should look as followed:
Form1 Insert Update Delete Buttons created at runtimeExplanation / Answer
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
struct emprec
{
int empid;
char *name;
};
typedef struct emprec emp;
void insert(char *a);
void display(char *a);
void update(char *a);
int count;
void main(int argc, char *argv[])
{
int choice;
while (1)
{
printf("Enter the choice ");
printf("1-Insert a new record into file 2-Display the records ");
printf("3-Update the record 4-Exit ");
scanf("%d", &choice);
switch (choice)
{
case 1:
insert(argv[1]);
break;
case 2:
display(argv[1]);
break;
case 3:
update(argv[1]);
break;
case 4:
exit(0);
default:
printf("Enter the correct choice ");
}
}
}
/* To insert a new recored into the file */
void insert(char *a)
{
FILE *fp1;
emp *temp1 = (emp *)malloc(sizeof(emp));
temp1->name = (char *)malloc(200 * sizeof(char)); //allocating memory for pointer
fp1 = fopen(a, "a+");
if (fp1 == NULL)
perror("");
else
{
printf("Enter the employee id ");
scanf("%d", &temp1->empid);
fwrite(&temp1->empid, sizeof(int), 1, fp1);
printf("Enter the employee name ");
scanf(" %[^ ]s", temp1->name);
fwrite(temp1->name, 200, 1, fp1);
count++;
}
fclose(fp1);
free(temp1);
free(temp1->name);
}
/* To display the records in the file */
void display(char *a)
{
FILE *fp1;
char ch;
int var = count;
emp *temp = (emp *)malloc(sizeof(emp));
temp->name = (char *)malloc(200*sizeof(char));
fp1 = fopen(a, "r");
if (count == 0)
{
printf("no records to display ");
return;
}
if (fp1 == NULL)
perror("");
else
{
while(var) // display the employee records
{
fread(&temp->empid, sizeof(int), 1, fp1);
printf("%d", temp->empid);
fread(temp->name, 200, 1, fp1);
printf(" %s ", temp->name);
var--;
}
}
fclose(fp1);
free(temp);
free(temp->name);
}
/* To Update the given record */
void update(char *a)
{
FILE *fp1;
char ch, name[200];
int var = count, id, c;
emp *temp = (emp *)malloc(sizeof(emp));
temp->name = (char *)malloc(200*sizeof(char));
fp1 = fopen(a, "r+");
if (fp1 == NULL)
perror("");
else
{
while (var) //displaying employee records so that user enter correct employee id
{
fread(&temp->empid, sizeof(int), 1, fp1);
printf("%d", temp->empid);
fread(temp->name, 200, 1, fp1);
printf(" %s ", temp->name);
var--;
}
printf("enter which employee id to be updated ");
scanf("%d", &id);
fseek(fp1, 0, 0);
var = count;
while(var) //loop to update the name of entered employeeid
{
fread(&temp->empid, sizeof(int), 1, fp1);
if (id == temp->empid)
{
printf("enter employee name for update:");
scanf(" %[^ ]s", name);
c = fwrite(name, 200, 1, fp1);
break;
}
fread(temp->name, 200, 1, fp1);
var--;
}
if (c == 1)
printf("update of the record succesfully ");
else
printf("update unsuccesful enter correct id ");
fclose(fp1);
free(temp);
free(temp->name);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.