Web forms and database interaction assignment description

Assignment Help Database Management System
Reference no: EM13765138

Web Forms and Database Interaction Assignment description:

STEP 1: Data Layer

Open Microsoft Visual Studio.NET 2008.

Click the ASP.NET project called PayrollSystem to open it.

Open the clsDataLayer class and add the following function:

// This function saves the personnel data

public static bool SavePersonnel(string Database, string FirstName, string LastName, string PayRate, string StartDate, string EndDate)

{

bool recordSaved;

try {

// Add your comments here

OleDbConnection conn = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Database);

conn.Open();

OleDbCommand command = conn.CreateCommand();

string strSQL;

// Add your comments here

strSQL = "Insert into tblPersonnel " + "(FirstName, LastName, PayRate, StartDate, EndDate) values ('" + FirstName + "', '" + LastName + "', " + PayRate + ", '" + StartDate +"', '" + EndDate + "')";

// Add your comments here

command.CommandType = CommandType.Text;

command.CommandText = strSQL;

// Add your comments here

command.ExecuteNonQuery();

// Add your comments here

conn.Close();

recordSaved = true;

} catch (Exception ex) {

recordSaved = false;

}

return recordSaved; }

In the frmPersonnelVerified form, go to the Page_Load() event and add the following code after the existing code (but in the Page_Load event handler):

// Add your comments here

if (clsDataLayer.SavePersonnel(Server.MapPath("PayrollSystem_DB.mdb"),

Session["txtFirstName"].ToString(),

Session ["txtLastName"].ToString(),

Session ["txtPayRate"].ToString(),

Session ["txtStartDate"].ToString(),

Session ["txtEndDate"].ToString()))

{

txtVerifiedInfo.Text = txtVerifiedInfo.Text +

"\nThe information was successfully saved!";

}

else

{

txtVerifiedInfo.Text = txtVerifiedInfo.Text +

"\nThe information was NOT saved.";

Add comments for all code containing // Add your comments here.

Test your work to make sure no errors occur! (Make sure to put in valid date values for the date data entry fields).

STEP 2: Data Display and Search

Using the skills you learned in Week 3, create a new DataSet for the tblPersonnel table (called the DataSet dsPersonnel).

Using the skills you learned in Week 3, create a new function called GetPersonnel in the clsDataLayer class. This function should retrieve all

data from the tblPersonnel table and return it in the form of a dsPersonnel DataSet. Use the GetUserActivity function as an example.
Create a new Web form called frmViewPersonnel.

Using the skills you learned in Week 3, add a GridView control (called grdViewPersonnel) to the form. This GridView control will be used to display data from the tblPersonnel table. Add the CoolBiz logo at the top of the page and make sure it links back to frmMain.

Add the following code to the Page_Load() function in frmViewPersonnel:

if (!Page.IsPostBack) {

// Declare the DataSet

dsPersonnel myDataSet = new dsPersonnel();

// Fill the dataset with what is returned from the function

myDataSet = clsDataLayer.GetPersonnel(Server.MapPath("PayrollSystem_DB.mdb"));

// Set the DataGrid to the DataSource based on the table

grdViewPersonnel.DataSource = myDataSet.Tables["tblPersonnel"];

// Bind the DataGrid

grdViewPersonnel.DataBind();

}

Return to the frmPersonnel Web form and add a button ((ID) = btnViewPersonnel, Text = View Personnel) which, when clicked, will display form frmViewPersonnel.

Using the skills you learned in Week 3, open the frmPersonnelVerified form and add a button ((ID) = btnViewPersonnel, Text = View Personnel) which, when clicked, will display form frmViewPersonnel. NOTE: This is the same button with the same functionality that you added to form frmPersonnel in the previous step. Also add a new link and linked image to frmMain called View Personnel that will go to the new frmViewPersonnel page you created.

You will now add a search feature to allow the user to find and display data. The user will enter a last name and the web application will display the grid of employees with all employees that match that last name.

Create a new web form called frmSearchPersonnel. Add the hyperlinked Cool Biz logo to this page. Also add a new item on frmMain (with a link button and image button) called Search Personnel.

On the frmSearchPersonnel form, add a label that displays "Search for employee by last name:". Next to the label, add a text box with an ID of txtSearchName. Add a button with an ID of btnSearch and set the text of the button to "Search".

When the frmSearchPersonnel Search button is pressed, the frmViewPersonnel is displayed. At this point, no searching is actually happening, but you have the forms you need and the navigation working. Now you can focus on the coding you will need to do to have the grid only display matching employees.

Before calling the GetPersonnel method you added previously in the lab, get the value that is in the Request["txtSearch"] item. When the form posts the search page results to the frmViewPersonnel, the name value pair for the search value is passed as part of the Request object. Assign this value to a string variable.

Modify the GetPersonnel method you added to include a new parameter called strSearch of type string. This parameter needs to be after the Database string parameter that is already in the method.

When calling the GetPersonnel method, pass the value you received to the strSearch parameter.
In the GetPersonnel method, you now need to use the passed in strSearch parameter value as part of the SQL string being used to retrieve data. You also need to add logic so that, if strSearch is empty or has no value, all employees are returned in the query.

Test the search so that when you enter a last name, employees with that last name are returned. Make sure that when you access frmViewPersonnel and you are not searching, all employees are returned.

Lab Hints:

Make sure you reestablish your database connection if you copied the files from a previous lab.

Before you pass the search value into the GetPersonnel method, make sure you check to see if the Request item is null. If it is, you need to pass an empty string into the method or check for null inside the method. If you don't do this, you will get a server error. To check to see if an object is null, you compare the object to the keyword null.

To create an SQL statement that will search for a given last name in the tblPersonnel table, you can do the following (assume that the search variable was called strSearch).

"select * from tblPersonnel where LastName = '" + strSearch + "'"

Add the new Search option and the View Employees option to your main navigation page.

STEP 3: Test and submit

Run your project and test it as follows:

The frmMain form should be displayed first (set this form as your start page).

Click on the Add New Employee hyperlink to go to the frmPersonnel data entry form. Click the View Personnel button on this form. The frmViewPersonnel form should be displayed in the browser, but at this point, there should not be any personnel listed (because you haven't entered any yet).

Use the Back button in your web browser to return to the frmPersonnel form and enter some personnel data, similar to the following:
Now click the Submit button. The frmPersonnelVerified form should be displayed, showing the data you entered, and you should get a message saying that the data was successfully saved, like this:

Finally, click the View Personnel data button on this form. The frmViewPersonnel form should be displayed and should show the personnel record you just entered, retrieved from the database, like this:

You also should be able to view the employee records by clicking the link on the home page.

Test the search feature and make sure that entering no search string returns all the data and that typing in a last name will return all employees with the same last name.

Reference no: EM13765138

Questions Cloud

What role does law enforcement play in these policies : What role does law enforcement play in these policies? Is there a difference between federal application and state and local application of policies
Prepare a schedule of cost of goods manufactured : Required: Prepare a Schedule of Cost of Goods Manufactured in the text box below
Capital budgeting problem : George and William Phelps are considering a 6 year project that would require a cash outlay of $80,000 for equipment and an additional $20,000 for working capital that would be released at the end of the project.
Evolution of criminal justice policy : Prepare a 1050-1400-word paper in which you conduct a comparative analysis of the evolution of criminal justice policy over the last 50 years for each of the three areas in criminal justice
Web forms and database interaction assignment description : Web Forms and Database Interaction Assignment description, public static bool SavePersonnel(string Database, string FirstName, string LastName, string PayRate, string StartDate, string EndDate)
Write paper on community-oriented policing : Select one of the following topics for your paper: Community-Oriented Policing, Terrorism-Security Policy for Large Events, Leave Policy for officers to work with governments in foreign countries
Security threat report : Determine whether or not you believe that the mobile device threats are the most critical and disturbing of all of the security threats presented in the articles. Provide a rationale for your response.
Describe how people acquire and change values : Describe how people acquire and change values. Explain the nature and importance of human values in the workplace
Purchased land-building-equipment from laguna corporation : Mohave Inc. purchased land, building, and equipment from Laguna Corporation for a cash payment of $919,800. The estimated fair values of the assets are land $175,200, building $642,400, and equipment $233,600. At what amounts should each of the three..

Reviews

Write a Review

Database Management System Questions & Answers

  An art museum that needs to track the artwork artists and

write a 750- to 1050-word paper in which you complete the followingmiddot choose a database environment from the

  Hsada systems analysis and design

Determine and confirm client business expectations and needs and determine and apply appropriate development methodologies

  Discuss how olap and data warehousing technologies

Discuss how OLAP and data warehousing technologies work together in solving user problems. What are the advantages and disadvantages of the different OLAP technologies (MOLAP, ROLAP, HOLAP)?

  Write the sql code that will save the changes

Write the SQL code to delete the row for William Smithfield and write the SQL code that will save the changes

  Identify the data types and sizes for all attributes

Select database management system (Oracle, SQL Server, MYSQL, etc) and identify the data types and sizes for all attributes

  Implement a database based on the provided er diagram

Analyse and comprehend a provided ER diagram and Database Schema and implement a database based on the provided ER diagram and Database Schema

  Complete a modified data dictionary for specialized register

Complete a modified data dictionary for a specialized registry/database for a disease or condition described in one of the scenarios that i will give to you

  How much of the total materials handling cost

How much of the total materials handling cost would be allocated to the wall mirrors - the materials handling cost is allocated on the basis of material moves

  Describe binary lock function

Describe relationships with example. Also illustrate degree of relationship for that example. What do you mean by locks. Write dow a binary lock function.

  Installation process between oracle 11g and oracle 10g

Create a document that will compare the installation process between Oracle 11g and Oracle 10g. Your submission document can be in the form of a MS Word document or a MS Excel spreadsheet. As long as you can adequately present your findings, the f..

  Create database to keep information of movies

Create a database for Ray. He is interested in movies and wants to keep information on movies, actors, and directors in a database. The only user is Ray, and he needs to produce reports.

  Translation from erd to the relational model

Complete (i.e., reverse engineering) ER diagram below such that 4 relation schemas above are exactly result of a translation from the ERD to the relational model.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd