CIS 407 Full Course - DevryOnlineHelp
301 views | +0 today
Follow
Your new post is loading...
Your new post is loading...
Scooped by Demetriaortega7
Scoop.it!

CIS 407 iLab 6 of 7: Login and Security Levels | DeVry Online Help

CIS 407 iLab 6 of 7: Login and Security Levels | DeVry Online Help | CIS 407 Full Course - DevryOnlineHelp | Scoop.it

http://www.devryonlinehelp.com/product/cis-407-ilab-6-of-7-login-and-security-levels/

Demetriaortega7's insight:

http://www.devryonlinehelp.com/product/cis-407-ilab-6-of-7-login-and-security-levels/

 

CIS 407 iLab 6 of 7: Login and Security Levels

STEP 1: Login Form (10 points)

 

Open Microsoft Visual Studio.NET 2008. Click the ASP.NET website named PayrollSystem to open it. Create a new web form named frmLogin. Drop a login control onto the form.  Set the properties of the login control as follows:

PROPERTY

VALUE

DestinationPageUrl

frmMain.aspx

TitleText

Please enter your UserName and Password in order to log into the system

Add the cool productions logo to the frmLogin form. Do not hylerlink the logo. Highlight everything in the form, then click Format, Justify, Center. Save your work. Go to the Solution Explorer, right-click on frmLogin, and left-click on Set As Start Page. Then run the website to check if the web form appears correctly.

STEP 2: Login Check (10 points)

 

Create a new DataSet called dsUser. Use the table tblLogin as the database table for this dataset. Do this in the same way you added datasets in the previous labs.  Open the clsDataLayer and add the following function:

// This function verifies a user in the tblUser table
public static dsUser VerifyUser(string Database, string UserName, string UserPassword)
{
// Add your comments here
dsUser DS;
OleDbConnection sqlConn;
OleDbDataAdapter sqlDA;

// Add your comments here
sqlConn = new OleDbConnection(“;” +
“Data mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:normal”> // Add your comments here
sqlDA = new OleDbDataAdapter(“Select SecurityLevel from tblUserLogin ” +
“where UserName like ‘” + UserName + “‘ ” +
“and UserPassword like ‘” + UserPassword + “‘”, sqlConn);

// Add your comments here
DS = new dsUser();

// Add your comments here
sqlDA.Fill(DS.tblUserLogin);

// Add your comments here
return DS;

}

Double-click on the login control you added. Add the following code to the login control Authenticate event handler:

// Add your comments here
dsUser dsUserLogin;

// Add your comments here
string SecurityLevel;

// Add your comments here
dsUserLogin = clsDataLayer.VerifyUser(Server.MapPath(“PayrollSystem_DB.mdb”),
Login1.UserName, Login1.Password);

// Add your comments here
if (dsUserLogin.tblUserLogin.Count < 1)
{
e.Authenticated = false;
return;
}

// Add your comments here
[0].SecurityLevel.ToString();

// Add your comments here
switch (SecurityLevel)
{

case “A”:
// Add your comments here
e.Authenticated = true;
Session["SecurityLevel"] = “A”;
break;
case “U”:
// Add your comments here
e.Authenticated = true;
Session["SecurityLevel"] = “U”;
break;
default:
e.Authenticated = false;

STEP 3: Test and Submit (10 points)

 

Open the frmPersonnel form and add the following code to its Page_Load() function:

// Add your comments here
if (Session["SecurityLevel"] == “A”) {

;

//Add your comments here
} else {

;

}

Set the start page as frmLogin.aspx. Run the website. Try to log in with both User and and User and Any other user ID and password should not allow you to log in. When the user logs in we want to restrict what they can see and do based on their user role. The role is stored in the database table tblUserLogin. Mickey Mouse has all privileges whereas Minnie Mouse has read only privileges. We want to control the visibility of the links on the frmMain page. Initially we did not set the ID of any of the Link Button or Image Button controls that we used on frmMain. In order to make our code more maintainable we will change the IDs as follows:

Option

Link Button ID

Image Button ID

Annual Salary Calculator

linkbtnCalculator

imgbtnCalculator

Add New Employee

linkbtnNewEmployee

imgbtnNewEmployee

View User Activity

linkbtnViewUserActivity

imgbtnViewUserActivity

View Personnel

linkbtnViewPersonnel

imgbtnViewPersonnel

Search Personnel

linkbtnSearch

imgbtnSearch

Edit Employees

linkbtnEditEmployees

imgbtnEditEmployees

Modify the main form so that the following options are turned off for nonadmin users:  Add New Employee View User Activity Edit Employees You now have a web application that honors the role of the logged in user. We don’t have a way of managing the user roles and users in the system. Add a new form called frmManageUsers that will allow the user to add new users. The user will also need to be able to view all users and modify or delete any of the users in the database. Add a main form option called Manage Users that is only accessible to admin users. Add the link and image buttons as we have done in the past. Add the CoolBiz logo that is hyperlinked as you did in previous assignments. For the security level of the user, use a dropdown list control to allow the user to select from A or U. Name the controls with names that make sense. Add code as appropriate to the code behind and clsDataLayer. Hints: Make sure you reestablish your database connection if you copied the files from a previous lab. Update any DataSource controls you added with the new Payroll database location. You can turn a control on or off by setting it’s Visible property. You can add a data entry form for new users and a grid displaying all users all on the same form. To force a gridView to refresh call its DataBind method. In order to use the Advanced SQL Generation option (allowing you to update/delete records) there must be a primary key defined on the table you are generating SQL for. tblUserLogin needs to have a primary key set on the UserID column. You can do this in Access. Test your application to make sure you are logging in with an invalid user id. Try to log in with both Minnie and Mickey and make sure the UI adjusts by the role properly. Make sure you can utilize the Manage Users functionality to add/modify/delete and view user information. Once you have verified that everything works, save your project, zip up all files, and submit in the Dropbox

more...
No comment yet.
Scooped by Demetriaortega7
Scoop.it!

CIS 407 iLab 4 of 7: Web forms with database interaction

http://www.devryonlinehelp.com/product/cis-407-ilab-4-of-7-web-forms-with-database-interaction/

Demetriaortega7's insight:

http://www.devryonlinehelp.com/product/cis-407-ilab-4-of-7-web-forms-with-database-interaction/

 

CIS 407 iLab 4 of 7: Web forms with database interaction

STEP 1: Data Layer (10 points)

 

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(“;” +
“Data Insert into tblPersonnel ” +
“(FirstName, LastName, PayRate, StartDate, EndDate) values (‘” +
FirstName + “‘, ‘” + LastName + “‘, ” + PayRate + “, ‘” + StartDate +
“‘, ‘” + EndDate + “‘)”;
// Add your comments here
;
;
// Add your comments here
command.ExecuteNonQuery();
// Add your comments here
conn.Close();
;
} catch (Exception ex) {
;

}

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()))
{
+
“\nThe information was successfully saved!”;

}
else
{
+
“\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 (10 points)

 

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 dsPersonnel();

// Fill the dataset with what is returned from the function
(Server.MapPath(“PayrollSystem_DB.mdb”));
// Set the DataGrid to the DataSource based on the table
["tblPersonnel"];

// Bind the DataGrid
grdViewPersonnel.DataBind();
}

Return to the frmPersonnel Web form and add a button ((ID) = btnViewPersonnel, 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, 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 ” Add the new Search option and the View Employees option to your main navigation page.

STEP 3: Test and submit (10 points)

 

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.

more...
No comment yet.
Scooped by Demetriaortega7
Scoop.it!

CIS 407 iLab 2 of 7: User Input Web Pages

http://www.devryonlinehelp.com/product/cis-407-ilab-2-of-7-user-input-web-pages/

Demetriaortega7's insight:

http://www.devryonlinehelp.com/product/cis-407-ilab-2-of-7-user-input-web-pages/

 

CIS 407 iLab 2 of 7: User Input Web Pages

STEP 1: frmPersonnel (10 points)

 

Open the payroll system website from Lab 1. Create a new form called frmPersonnel. To do this, pull down the website menu, select “Add New Item,” then type frmPersonnel.aspx for the name.  Go to the Design mode of the form by clicking the Design tab (as opposed to the Source tab). Copy/paste this text for the cool biz production  logo onto the form at the very top. Set the alignment to center by highlighting the text then clicking Format, Justify, Center. You can switch to Source view and add the following HTML to create the logo: From the ToolBox, drag-and-drop a Panel control underneath the logo text. Click the A/Z button in the Properties dialog so that all the properties are sorted alphabetically.  Change the height property of the Panel to 250px and the width to 300px. To do this, select the Panel, then go to the Properties pane (usually in the lower right corner of the Visual Studio.NET Design view; if you don’t see it, click View Properties Window OR press the F4 key). Scroll down the list, then type the value in for each property. Change the panel’s HorizontalAlign property to left. Save your work! From the ToolBox, drag-and-drop five Labels and five TextBoxes onto the Panel. To make each Label/TextBox pair appear on a separate line, put the cursor after each TextBox then press the [ENTER] key (much like you would with a word processing program). From the ToolBox, drag-and-drop two buttons onto the Panel below the last Label and TextBox. Save your work! Test your web page. Press F5, or click the Start Debugging (Citrix users, press “Start Without Debugging”) button on the toolbar, or pull down the Debug menu and select Start Debugging.
NOTE: To execute the application, you have these options: If you are using Citrix, press CTRL + F5 to Start Without Debugging. You will not be deducted points for this part. If you are using a standalone version, press F5 to Start with Debugging, or you can press CTRL + F5 to Start Without Debugging Rename the Label’s properties as defined below. You can do this by selecting each Label, scrolling to the property, and then typing in the value.

Property

Value

Label1 – Text

First Name:

Label2 – Text

Last Name:

Label3 – Text

Pay Rate:

Label4 – Text

Start Date:

Label5 – Text

End Date:

Rename each TextBox’s property as defined below. You can do this by selecting each TextBox, scrolling to the property, and then typing in the value.

Property

Value

TextBox1 – (ID)

txtFirstName

TextBox2 – (ID)

txtLastName

TextBox3 – (ID)

txtPayRate

TextBox4 – (ID)

txtStartDate

TextBox5 – (ID)

txtEndDate

Change each button’s ID and Text properties as defined below. You can do this by selecting each button, scrolling to the property, and then typing in the value.

Property

Value

Button1 – (ID)

btnSubmit

Button1 – Text

Submit

Button2 – (ID)

btnCancel

Button2 – Text

Cancel

In order to format the TextBoxes and Labels, we will make them the same size. Bring up the Layout Toolbar by clicking View, Toolbars, Layout. Highlight each Label by pressing and holding the keyboard Ctrl button and then clicking each Label. Make sure you click on the longest Label last. Click the icon “Make Same Width” on the Layout Toolbar. (You may also select Format and then Make Same Size and then select width). Save your work! Test your work by running it (press F5 or click the Start Debugging button, or click Debug, Start Debugging).

STEP 2: frmPersonalVerified (5 points)

 

Create a new web form called frmPersonalVerified.aspx Click the Design tab for the frmPersonalVerified.aspx and add a Label and a TextBox. Set the properties as follows:

Property

Value

Label – Text

Information to submit

Textbox – (ID)

txtVerifiedInfo

Textbox – Height

80px

Textbox – Width

400px

Textbox – TextMode

Multiline

Double-click anywhere on a blank part of the web page to open the code portion. The cursor should be in the protected void Page_Load (object sender, EventArgs) function. Enter the following information:

  //Add your comments here
["txtFirstName"] +
“\n” + Request["txtLastName"] +
“\n” + Request["txtPayRate"] +
“\n” + Request["txtStartDate"] +
“\n” + Request["txtEndDate"];

Return to the frmPersonnel web page, click the btnSubmit button, go to the PostBackUrl property, and set it to frmPersonalVerified.aspx. To do this, you can click the ellipse to the right of this property to open a Browse dialog and click frmPersonalVerified.aspx there. This will insert the correct path into the PostBackUrl property.

STEP 3: Adding Navigation (5 points)

 

Create a folder in Solution Explorer called images. Add a new web form called frmMain. Add the CoolBiz Logo to the top of the form (centered). Create links using a link button for each of the following items.

Salary Calculator
Add New Employee Create or find appropriate images for the Salary Calculator and New Employee links. Copy the images to the images folder created above. Add the images to the images folder by right-clicking on the images folder in Solution Explorer and selecting Add Existing Items. Select both images and Add to the images folder. Next to each link item, add an image button. Set each image button’s image to the appropriate image in the images folder. You may work with the format to make this page look nice by using tables or other HTML/CSS elements. Set the PostbackURL property to the appropriate page for each image and each link. On the frmPersonnel page, make the CoolBiz logo be a link that will take the user to the frmMain page. Use an ASP.Net Hyperlink control to do this. Update the frmPersonnel, frmPersonnelVerified, and frmSalaryCalculator to include the CoolBiz logo at the top of each page (centered) with the logo set as a hyperlink that will return to the frmMain page. On the frmPersonnel page, make it so that if the user presses the Cancel button then that user is taken back to the frmMain.

STEP 4: Verify and Submit (10 points)

 

Save your work. Set the start page to frmMain and run the project. You should be able to go to both areas of your site and enter the information in the pages. Your calculator should properly calculate without errors, and then on the frmPersonel web page you can click the Submit button and have it display in the frmPersonalVerified web page. Once you have verified that it works, save your project, zip up all files, and submit in the Dropbox.

more...
No comment yet.
Scooped by Demetriaortega7
Scoop.it!

CIS 407 Final Exam | DeVry Online Help

http://www.devryonlinehelp.com/product/cis-407-final-exam-2/

Demetriaortega7's insight:

http://www.devryonlinehelp.com/product/cis-407-final-exam-2/

 

1. (TCO 1) In order to design Web forms in Visual Studio.NET, we use the _______.

2. (TCO 1) Many of the Web server controls have a _______ menu, which allows developers options to perform common tasks and settings

3. (TCO 1) The starting page for the website can be changed by _______.

4. (TCO 2) _______ allow users to select controls by keyboard shortcuts

5. (TCO 2) You can use the ________ to specify the maximum amount of characters that can be entered in a textbox

6. (TCO 2) The CheckedChanged Event for a radio button occurs _________.

7. (TCO 3) You can use ________ to track the state of each user in the application.

8. (TCO 3) The ________ control displays the navigation as menu options

9. (TCO 3) ________ variables are maintained while the browser is opened

10. (TCO 4) To create an SQLDataSource from the Designer, developers can _______.

11. (TCO 5) _______ is the ability for the GridView to display data one page at a time.

12. (TCO 5) The ________ layer is used to contain the data for the application.

13. (TCO 6) Transaction objects in .NET contain methods to

14. (TCO 6) _________ starts the transaction process

15. (TCO 6) _________ reverts the changes in the database

16. (TCO 6) _________, in transaction processing, means that managed resources survive failures

1. (TCO 7) You need _______ in order to add one or more Views to a control

2. (TCO 7) A _________ control can be implemented to allow users to step through a process

3. (TCO 7) The _________ part of ASP.NET Web pages can contain a combination of Web controls, user controls, and HTML syntax

4. (TCO 9) SMTP sends e-mails in _______ format.

5. (TCO 9) A _______ is a web page that can be easily customized by users.

6. (TCO 9) The ________ file controls the configuration of the ASP.Net Web application.

7. (TCO 1) An absolute URL is _______.

8. (TCO 1) When you bind a dropdown list to a data grid, the system will _______.

9. (TCO 1) A _________ is a website that is located on your local computer

10. (TCO 2) You can use the ________ to specify the maximum amount of characters that can be entered in a textbox

11. (TCO 2) The CheckedChanged Event for a radio button occurs _________.

12. (TCO 2) The Rows and SelectionMode properties apply to _______.

13. (TCO 3) You can use ________ to track the state of each user in the application

14. (TCO 3) ________ values are stored in the memory of the ASP.NET process.

15. (TCO 9) In IIS, you can create a _____ directory, which points to a location other then (THAN) the directory you create for the project

1. (TCO 1) Describe three components found in the Application Layer

2. (TCO 2) Describe one item that needs to be kept in mind when designing web forms for the Presentation Layer of an N-Tier Architecture

3. (TCO 3) Describe the ASP.NET session state object and give one example of what it can be used for in a web application

4. (TCO 4) Describe two advantages of using stored procedures instead of inline SQL.

5. (TCO 5) List the seven general steps involved in creating a Web-based data-driven application that uses a bound control to display data from a database

more...
No comment yet.
Scooped by Demetriaortega7
Scoop.it!

CIS 407 All 7 Weeks ilabs | DeVry Online Help

CIS 407 All 7 Weeks ilabs | DeVry Online Help | CIS 407 Full Course - DevryOnlineHelp | Scoop.it

http://www.devryonlinehelp.com/product/cis-407-all-7-weeks-ilabs/

Demetriaortega7's insight:

http://www.devryonlinehelp.com/product/cis-407-all-7-weeks-ilabs/

 

CIS 407 iLab 1 of 7: “Annual Salary Calculator” ASP.NET Web ApplicationCIS 407 iLab 2 of 7: User Input Web PagesCIS 407 iLab 3 of 7: User activity monitoringCIS 407 iLab 4 of 7: Web forms with database interactionCIS 407 iLab 5 of 7: Transaction ProcessingCIS 407 iLab 6 of 7: Login and Security LevelsCIS 407 iLab 7 of 7: Error Notification via E-Mail
more...
No comment yet.
Scooped by Demetriaortega7
Scoop.it!

CIS 407 iLab 5 of 7: Transaction Processing

http://www.devryonlinehelp.com/product/cis-407-ilab-5-of-7-transaction-processing/

Demetriaortega7's insight:

http://www.devryonlinehelp.com/product/cis-407-ilab-5-of-7-transaction-processing/

 

CIS 407 iLab 5 of 7: Transaction Processing

STEP 1: Modify the clsDataLayer to use a two-step process (10 points)

 

Open Microsoft Visual Studio.NET 2008. Click the ASP.NET project called PayrollSystem to open it. Open the clsDataLayer class. Modify the SavePersonnel() function so that instead of just doing a single SQL INSERT operation with all the personnel data, it does an INSERT with only the FirstName and LastName, followed by an UPDATE to save the PayRate, StartDate, and EndDate into the new record. (This two-step approach is not really necessary here because we are dealing with only one table, tblPersonnel, but we are doing it to simulate a case with more complex processing requirements, where we would need to insert or update data in more than one table or maybe even more than one database.) Find the following existing code in the SavePersonnel() function:

// Add your comments here
+
“(FirstName, LastName, PayRate, StartDate, EndDate) values (‘” +
FirstName + “‘, ‘” + LastName + “‘, ” + PayRate + “, ‘” + StartDate +
“‘, ‘” + EndDate + “‘)”;

// Add your comments here
;
;

// Add your comments here
command.ExecuteNonQuery();


Modify it so that it reads as follows:

// Add your comments here
+
“(FirstName, LastName) values (‘” +
FirstName + “‘, ‘” + LastName + “‘)”;

// Add your comments here
;
;

// Add your comments here
command.ExecuteNonQuery();

// Add your comments here
+
“Set , ” +
“, ” +
” ” +
“Where ID=(Select Max(ID) From tblPersonnel)”;

// Add your comments here
;
;

// Add your comments here
command.ExecuteNonQuery();

Set frmMain as the startup form and run the PayrollSystem Web application to test the changes. When valid data values are entered for a new employee, things should work exactly as they did before. To test this, enter valid data for a new employee in frmPersonnel and click Submit. The frmPersonnelVerified form should be displayed with the entered data values and a message that the record was saved successfully. Click the View Personnel button and check that the new personnel record was indeed saved to the database and that all the entered data values, including the PayRate, StartDate, and EndDate, were stored correctly. Close the browser window. Now run the PayrollSystem Web application again, but this time enter some invalid data (a nonnumeric value) in the PayRate field to cause an error, like this: Now when you click Submit, the frmPersonnelVerified form should display a message indicating the record was not saved: However, when you click on the View Personnel button to display the personnel records, you should see that an incomplete personnel record was in fact created, with missing values for the PayRate, StartDate and EndDate fields: This occurred because the Insert statement succeeded but the following Update statement did not. We do not want to allow this to happen because we end up with incomplete or incorrect data in the database. If the Update statement fails, we want the Insert statement to be rolled back, or undone, so that we end up with no record at all. We will fix this by adding transaction code in the next step.

STEP 2: Add transaction code (10 points)

 

In the clsDataLayer.cls class file, add code to the SavePersonnel() function to create a transaction object. Begin the transaction, commit the transaction if all database operations are successful, and roll back the transaction if any database operation fails. The following listing shows the complete SavePersonnel() function; the lines you will need to add are marked with ** NEW ** in the preceding comment and are shown in bold.

// This function saves the personnel data
public static bool SavePersonnel(string Database, string FirstName, string LastName,
string PayRate, string StartDate, string EndDate)
{
bool recordSaved;

  // ** NEW ** Add your comments here
OleDbTransaction ;

try
{

// Add your comments here
OleDbConnection OleDbConnection(“;” +
“Data font-size:8.5pt;font-family:”Arial”,”sans-serif”; mso-fareast-font-family:”Times New Roman””>

// ** NEW ** Add your comments here
();
;

// Add your comments here
+
“(FirstName, LastName) values (‘” +
FirstName + “‘, ‘” + LastName + “‘)”;

// Add your comments here
;
;

// Add your comments here
command.ExecuteNonQuery();

// Add your comments here
+
“Set , ” +
“, ” +
” ” +
“Where ID=(Select Max(ID) From tblPersonnel)”;

// Add your comments here
;
;

// Add your comments here
command.ExecuteNonQuery();

// ** NEW ** Add your comments here
myTransaction.Commit();

// Add your comments here
conn.Close();

;

}
catch (Exception ex)
{

// ** NEW ** Add your comments here
myTransaction.Rollback();

;

}

return recordSaved;

}

Run your Web application. First, enter valid data in all the fields of frmPersonnel. When you press the Submit button in frmPersonnel, a record should be saved in the tblPersonnel table containing the FirstName, LastName, PayRate, StartDate, and EndDate. With valid data entered in all the items, the “successfully saved” message should appear indicating that the transaction was committed. Click the View Personnel button and verify that the new record was in fact added to the database table correctly. Now close the browser, run the Web application again, and this time test that the transaction will roll back after entering incorrect information. On the frmPersonnel form, enter invalid data for PayRate and click Submit. The “not saved” message should appear, which indicates that the transaction was rolled back. Click the View Personnel button and verify that this time, as desired, an incomplete record was not added to the database table. You have seen how we used the try/catch block to catch an unexpected error. You may have noticed that if you enter bad data for the dates, an exception is thrown. Go back to the validation code you added in the frmPersonnel code and add a try/catch with logic to prevent an invalid date from causing a server error. In the Week 3 and Week 5 labs, you learned how to validate code once the page was posted back to the server. There is some validation that must be done on the server because it requires server resources such as the database. Some validation can also be done on the client. If you can do validation on the client it saves a round trip to the server, which will improve performance. In this approach, we will check values before the page is submitted to the server for processing. Normally, there is a combination of server and client validation used in a web application. ASP.Net includes validation controls which will use JavaScript on the client to perform validation. You will find these controls in the Validation group in the toolbox. Add validation controls to the frmPersonnel form as follows: For the first and last name, make sure each field has data in it. Use the RequiredFieldValidator for this. Add the control to the right of the text box you are validating. The location of the validator control is where the error message (if there is one) will appear for the control you link the validator to. You will be adding one validator control for each text box you want to validate. Remember to set the ControlToValidate and ErrorMessage properties on the validator control. Making this change eliminates the need for the server-side check you were doing previously. Use a regular expression validator to check that the start and end date are in the correct format. Remove the View Personnel and Cancel buttons from the frmPersonnel form as they will cause a Postback and invoke the client-side editing you just added. The user is able to get to the View Personnel from the main form and from the personnel verification screen, so there is no need for these buttons now. Because you have entered data in this lab that is invalid and those partial records are in the database, you will need to add the ability to remove or update data. Add a new main form option called Edit Employees. Add the link and image for this. This option will take the user to a new form called frmEditPersonnel. Add the new form frmEditPersonnel. On frmEditPersonnel, add the CoolBiz log at the top of the form. Add a label that says “Edit Employees.” Add a GridView control with an ID of grdEditPersonnel. You will now add a SQLDataSource to the page. You will be using a databound grid for this form unlike the previous grids, in which you added as unbound (in the designer). Add a new SQLDataSource control to the frmEditPersonnel in the design view. This is not a visible control; that is, it will only appear in design view but the user will never see it. Note: If you change the folder name or location of your database, you will need to reconfigure the data source (right-click on the data source control and select the “Configure Data Source” option. There is a small > indicator in the design view of the SQL Data Source control you added if the configuration menu is collapsed (press it to open the menu), or there is a < with the menu displayed. From the data source menu, select “Configure Data Source.”  Press the New Connection button and select the database. Press the Next button. When asked if you want to save the connection in the application configuration file, check the Yes check box and press Next. Select the tblPersonnel table. Select all columns (you can use the * for this). Press the Advanced button and check the Generate Insert, Update, and Delete option and press the OK button. Press the Next button. Press the Test Query button and make sure everything works as it is supposed to. If it does not repeat the above steps to make sure you did everything properly. Press the Finish button. Click on the grid you added in the design view and expand the properties menu (the little > in the upper right of the control). Choose the data source you just added. On the GridView tasks menu, select Edit columns. Add an Edit, Update, and Cancel Command field. Add a Delete Command field. Press OK. You can now test the grid, which is a fully functioning Update and Delete grid. Try it out! Hints:

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

In order to keep the validation controls from causing wrapping, you may want to increase the Panel width.

A regular expression for mm/dd/yyyy is this:

^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d$

Experiment with the editable grid and command buttons for different display styles.

more...
No comment yet.
Scooped by Demetriaortega7
Scoop.it!

CIS 407 iLab 3 of 7: User activity monitoring | DeVry Online Help

CIS 407 iLab 3 of 7: User activity monitoring | DeVry Online Help | CIS 407 Full Course - DevryOnlineHelp | Scoop.it

http://www.devryonlinehelp.com/product/cis-407-ilab-3-of-7-user-activity-monitoring/

Demetriaortega7's insight:

http://www.devryonlinehelp.com/product/cis-407-ilab-3-of-7-user-activity-monitoring/

 

CIS 407 iLab 3 of 7: User activity monitoring

STEP 1: Data Connection, Dataset and Data Access Class (10 points)

 

Open Microsoft Visual Studio.NET 2008. Open the PayrollSystem website by clicking on it in the Recent Projects list, or by pulling down the File menu, selecting Open Website, navigating to the folder where you previously saved the PayrollSystem, and clicking Open. Download the PayrollSystem_DB.MDB file from Doc Sharing and save it on your local computer. (Note: your operating system may lock or block the file. Once you have copied it locally, right click on the file and select Properties and then Unblock if available). Then add it to the PayrollSystem website as follows: In Visual Studio, in the Solution Explorer click Website, Add Existing Item, then navigate to the PayrollSystem_DB.MDB file you downloaded and click the Add button. Now we need to create a new connection to the PayrollSystem_DB.MDB. To begin, click View Server Explorer. When the Server Explorer toolbox appears, click the Connect to Database button. When the Add Connection dialog appears, click the Change button. In the “Change Data Source” dialog, select MS Access Database File; Uncheck Always use this Selection; then click OK. Click the Browse button to navigate to the PayrollSystem_DB.mdb file in your website folder, then click “Open”. (NOTE: Be sure you select the PayrollSystem_DB.mdb file in your PayrollSystem website folder, not the one you originally downloaded from Doc Sharing!) Click Test Connection. You should receive a message that the test connection succeeded. Click OK to acknowledge the message, then click “OK” again to close the Add Connection dialog. The PayrollSystem_DB.mdb should be added to the Server Explorer. Expand the database, then expand the Tables entry under the database until you see tblUserActivity. Leave the Server Explorer window open for now as you will be returning to it in a moment. Create a new dataset by selecting Website Add New Item. Under Templates, select the Dataset item. Enter dsUserActivity.xsd for the name. Click Add.  If the following message appears, select Yes. You want to make this dataset available to your entire website. If the TableAdapter Configuration Wizard dialog appears, click Cancel. (We will be configuring a Data Adapter for this dataset later in C# code, so we do not need to run this wizard.)  Drag-and-drop the tblUserActivity table from the Server Explorer window into the dsUserActivity dataset in the editor window. 

NOTE: If you see a message that says your connection uses a local data file that is not in the current project, that indicates you did not select the correct PayrollSystem_DB.mdb file when you created your data connection. To fix this problem, click No, then right-click on PayrollSystem_DB.mdb in the Server Explorer window and choose Modify Connection. Click the Browse button, navigate to the PayrollSystem_DB.mdb file that is in your PayrollSystem website folder, and click Open. Test the connection, then click OK. Click the Save icon on the toolbar to save the dsUserActivity.xsd dataset.
(You can now close the Server Explorer window if you wish.) Create a new class to contain the C# code that will access this dataset. To do so, click Website, Add New Item. In the Add New Item dialog, select the Class template, and enter clsDataLayer for the name. Make sure the Language is set to Visual C#. Click “Add”. If the following message appears, select Yes. You want to make this class available to everything in your solution. Add the following to the top of your class, below any other using statements created for you by Visual Studio:

// Add your comments here
using System.Data.OleDb;
using System.Net;
using System.Data;

Add the following three functions inside the squiggly braces for the “public class clsDataLayer” class, above the beginning of the “public clsDataLayer()” constructor:

// This function gets the user activity from the tblUserActivity
public static dsUserActivity GetUserActivity(string Database)
{
// Add your comments here
dsUserActivity DS;
OleDbConnection sqlConn;
OleDbDataAdapter sqlDA;

// Add your comments here
OleDbConnection(“;” +
“Data font-size:8.5pt;font-family: “Arial”,”sans-serif”;mso-fareast-font-family:”Times New Roman””>

// Add your comments here
OleDbDataAdapter(“select * from tblUserActivity”, sqlConn);

// Add your comments here
dsUserActivity();

// Add your comments here
sqlDA.Fill(DS.tblUserActivity);

// Add your comments here
return DS;
}

// This function saves the user activity
public static void SaveUserActivity(string Database, string FormAccessed)
{
// Add your comments here
OleDbConnection OleDbConnection(“;” +
“Data font-size:8.5pt;font-family:”Arial”,”sans-serif”;mso-fareast-font-family: “Times New Roman””>

+
GetIP4Address() + “‘, ‘” + FormAccessed + “‘)”;

;
;
command.ExecuteNonQuery();
conn.Close();
}

// This function gets the IP Address
public static string GetIP4Address()
{
string IP4Address  = string.Empty ;

foreach (IPAddress IPA in
Dns.GetHostAddresses(HttpContext.Current.Request.UserHostAddress)) {
if (IPA.AddressFamily.ToString() == “InterNetwork”) {
();
break;
}
}

if (IP4Address != string.Empty) {
return IP4Address;
}

foreach (IPAddress IPA in Dns.GetHostAddresses(Dns.GetHostName())) {
if (IPA.AddressFamily.ToString() == “InterNetwork”) {
();
break;
}
}

return IP4Address;
}

STEP 2: frmUserActivity, frmPersonnel, frmMain (10 points)

 

Create a new Web form called frmUserActivity. Switch to Design Mode and add a Label and GridView (found under the Toolbox, Data tab) having the following properties:

Property

Value

Label – Text

User Activity

GridView – (ID)

grdUserActivity

Go to the Page_Load method and add the following code:

if (!Page.IsPostBack) {
// Declares the DataSet
dsUserActivity dsUserActivity();

// Fill the dataset with what is returned from the function
(Server.MapPath(“PayrollSystem_DB.mdb”));

// Sets the DataGrid to the DataSource based on the table
["tblUserActivity"];

// Binds the DataGrid
grdUserActivity.DataBind();
}

Open the frmMain form, add a new link button and image button to point to the new frmUserActivity. Find an image to use for the image button and add the new option as View User Activity.  Go to the frmMain Page_Load and add the following code:

// Add your comments here
clsDataLayer.SaveUserActivity(Server.MapPath(“PayrollSystem_DB.mdb”), “frmPersonnel”);

On the frmUserActivity form, add the CoolBiz logo hyperlinked logo at the top of the page so that when clicked the user is returned to frmMain. In the Solution Explorer, right click on the frmMain.aspx form and select Set As Start Page. Run your project. When you open the project, a record should be saved in the tblUserActivity table with the IP address, form name accessed (frmPersonnel), and the date accessed. When you click the View Activity button, you should see at least one record with this information. You will now add server side validation code to the frmPersonnel page. Currently, when the Submit button is pressed, the frmPersonnelVerified page is displayed. This is because the frmPersonnelVerified page is set as the Submit button’s PostBackUrl property. Instead of having the page go directly to the frmPersonnelVerified page when the Submit button is pressed, we want to do some server side validation. If any of the validation rules fail, we will redisplay the frmPersonnel page with the fields in question highlighted in yellow with an error message displayed.

First, it is important to understand what is currently happening when the submit button is pressed. This is causing a postback of the form to the frmPersonnelVerified form. When this postback happens, all of the data in the fields on the frmPersonnel form are sent to the frmPersonnelVerified form as name value pairs. In the Page_Load code of frmPersonnelVerified these values are picked up from the Request object and displayed. Each name value pair will be in the Request object as the ID of the control containing the value and the value itself. We can pass data between pages by using Session state instead. In order to do validation on the values but still have the values visible on the frmPersonnelVerified page, we will need to change not only the PostBack URL of the frmPersonnel page but also how the frmPersonnelVerified form is getting the data – it will need to get it from Session state rather than from the Request object.

Make the following changes:

Clear the Submit button PostBackURLProperty on the frmPersonnel form. In the btnSubmit_Click event handler get each value from the data entry fields and set Session state items for each. Change the frmPersonnelVerified code behind to get the values from the Session state items you created in the previous step.

When you are done with these steps, you should be able to enter data on the frmPersonnel data entry form and then click the Submit button. The frmPersonnelVerified page should then be displayed with the values that were in the data entry fields on frmPersonnel.

Make sure this is all working before proceeding to the next steps.

Add a label to the frmPersonnel form with an ID of lblError. Do not place the label to the right or left of any of the controls on the form. Add it below the controls or above the controls. The text property of this label should be set to an empty string. Add code to perform server side validation in response to the submit button being clicked. Here are the business rules we want to enforce (remember this will be server C# code in the frmPersonnel code behind): Fields may not be empty or filled with spaces. If any field is empty, turn that field background color to yellow and add to/create an error message to be shown in the error label. The end date must be greater than the start date. If the end date is less than the start date, turn both date fields yellow and add to/create an error message to be shown in the error label. If all fields validate properly then the session state items should be set properly and the user should see the frmPersonnelVerified form with all the values displayed. Lab Hints: To set a value in session state do the following:

Session["txtFirstName"] = txtFirstName.Text;

28.  “txtFirstName” is the key and txtFirstName.Text is the value.

29.  To get this same value back from the session we use the key and the Session object as follows:

Session["txtLastName"].ToString()

30.  There is a Trim method on the string object that will automatically remove spaces from the beginning and end of a string. Remember, you can turn an object like a Session item object into a string using the Convert class or just using it’s ToString() method.

31.  You may want to create variables to work with for validation rather than using the Request item objects directly.

32.  To turn a string into a DateTime object you can use the DateTime method Parse. If you had a date value stored in a string called strDate, you could turn it into a DateTime object like this:

DateTime (strDate);

33.  You can compare two DateTime objects by using the DateTime.Compare method. If you had two DateTime objects called dt1 and dt2 you can check to see if dt1 is greater than dt2 by doing this:

if (DateTime.Compare(dt1,dt2) > 0)

34.  DateTime.Compare will return a 0 if the two dates are equal, a 1 if dt1 is greater than dt2, and a -1 if dt1 is less than dt2.

35.  If you put in an invalid date for either of the date fields, you will get an exception/server error when trying to parse the values. We will address this in a later lab – for now make sure you enter valid dates (valid meaning a date in the form of mm/dd/yyyy).

36.  If I had a TextBox control that was called txtAge and you wanted to set it’s background color you could do this:

Color.Yellow;

37.  Remember to clear the PostBackURL property of the submit button!

more...
No comment yet.
Scooped by Demetriaortega7
Scoop.it!

CIS 407 iLab 1 of 7: "Annual Salary Calculator" ASP.NET Web Application | DeVry Online Help

CIS 407 iLab 1 of 7: "Annual Salary Calculator" ASP.NET Web Application | DeVry Online Help | CIS 407 Full Course - DevryOnlineHelp | Scoop.it

http://www.devryonlinehelp.com/product/cis-407-ilab-1-of-7-annual-salary-calculator-asp-net-web-application/

Demetriaortega7's insight:

http://www.devryonlinehelp.com/product/cis-407-ilab-1-of-7-annual-salary-calculator-asp-net-web-application/

 

CIS 407 iLab 1 of 7: “Annual Salary Calculator” ASP.NET Web Application

STEPS 1 through 3: Create Website and Home Page (10 points)

 

In this ilab, we will learn how to create a simple ASP.NET web application using Microsoft Visual Studio.NET 2008. The application will display the text “Hello, World” on the home page.

Open Microsoft Visual Studio 2008.

2.  Create a new ASP.NET website called “PayrollSystem.” To do this, select “File, New Website

When the “New Website” dialog opens, select “ASP.NET Website” as the Template, select “File System” as the Location, and select “Visual C#” as the Language. Click Browse and navigate to the folder where you want to save your website. Add “PayrollSystem” at the end of the file path. Click OK if you are prompted to create a new folder. Click OK in the New Website dialog to finish creating the website.

Edit the Default.aspx file (the home page for your site) to add the message “Hello, World.” To do this, if necessary, click the Design button below the editing window to switch to Design view, then click in the editing window and type “Hello, World” (without the quotes).

Click the Save button on the toolbar to save the changes to Default.aspx.

STEPS 4 through 5: Start Debugging (10 points); NOTE: Citrix users have different steps!

 

To ensure that everything is working properly, click the Start Debugging button on the toolbar, or press the F5 key on the keyboard, or pull down the Debug menu and select “Start Debugging.” If the “Debugging Not Enabled” dialog box appears, select the option to add or modify the Web.config file to enable debugging and click OK. You should only have to do this the first time you debug the site.

STEP 6 through 7 : Display the “Hello, World” web page (10 points)

 

The Internet Explorer web browser will open and display your Default.aspx page containing the “Hello, World” message. Stop debugging and return to the design mode by closing the browser.  Add a new form to your web application called frmSalaryCalculator.aspx. Make sure “Place Code in separate file” is checked when you add the form. To add a new form, click (single-click, not double-click) on the project node in the solution explorer.

With the project node highlighted, right-click on the project node and select “Add New Item” from the popup menu. The following dialog will be displayed:

Select the name of the form you will add frmSalaryCalculator.aspx. Make sure “Place code in separate file” is checked and “Select master page” is unchecked.

You will create a web-based salary calculator on this new page. To do this, open the aspx page in Design view and, from the Toolbox, add three labels, two text box controls, and a button control. You can add controls by dragging the control from the Toolbox – Standard section onto your form. Your form should look like this:Change the text displayed in each label so that the first label displays “Annual Hours”; the second label should display “Rate” and the third label should display “$”. (Hint: To change the text displayed, change the Text property of each control.) Change the button text to display “Calculate Salary.” (Hint: To change the text displayed as the button label, change the Text property of the button.) Your form should now look like this: Set the ID property of the top text box to txtAnnualHours. Set the ID property of the second textbox to txtRate. Set the ID of the bottom label (the one we set the text property to “$”) to lblSalary. (Note: We set these IDs as we will be accessing the control values from the C# code. You can set the button ID and the other two labels’ ID properties as well, but we won’t be accessing them from our code.) In Design view, add a C# event handler for the button-click event by double-clicking on the Calculate Salary button. This will place you in the page code behind file the editor. (Remember that ASP.Net pages have a file containing the HTML markup with an extension of .aspx and a C# ‘code behind’ file with an extension of .aspx.cs.) This is the code that should be displayed: (If you changed the ID of the button, it will be a different method name.)

This code will be called each time the user presses the button. It is important to remember that code in the code behind page executes on the server – not on the user’s browser. This means that when the button is pressed, the page is submitted back to the web server and is processed by the ASP.Net application server on the web server. It is this code (between the { and } in this method) that will execute on the server. Once it is done executing the page will be sent back to the browser. Any changes we make to the page or controls on the page will be shown to the user in the updated page.

In this method, add code that will get the text in the txtAnnualHours text box, convert it to a Double, and store it in a double variable. Add code that will get the text from the txtRate text box, convert it to a Double, and store it in another variable. Create a third variable of type Double and set its value to the annual hours variable value multiplied by the rate double variable value. Take this resulting value and convert it to a string (text), and update the lblSalary Text property with this new string.

Hints:

A control’s property can be accessed by simply using the control ID followed by a . followed by the name of the property. For example, the value stored in the Text property of the txtAnnualHours control can be accessed by using this: txtAnnualHours.Text. Text properties on controls are of type string.

To convert a string to a Double you can use the Convert class. If we had a string variable called str1 and a double variable called myNumber, the C# code to convert this would be as follows:

When converting from one type to another, we are assuming that the value stored in the type being converted is compatible with the type we are converting to. In the example above, if the value stored in str1 was not type compatible with a Double (for example “tiger”) an error would be raised.

To set the value of a control on a web form, you can access the control and set the property directly. If I had a label control called lblCar and I wanted to update the text that was displayed in the label, I could do something like this:

Note that following code would be incorrect and cause an error:

lblCar is a Label – it isn’t a string so we can’t assign a string directly to it, but we can assign a string directly to the Text property of the label.

All of the base types in C# (double, int etc) have a ToString() method you can call. If you had a double variable that you wanted to convert to a string and set that string to my label’s text, you would do the following:

This would take whatever value was stored in the myNumber Double and convert it to a string.

To add a $ to output you can use string concatenation in C# like this:

Set your new form as the start page by clicking once on the form name in the Solution Explorer and then right-clicking on the form name and selecting “Set as Start Page.” You can now test your application and make sure it works correctly as you did with the Hello World form above. You can switch back and forth between which form runs when you run your application by setting the different forms as the start page.

Once you have verified that your project works, save your project, zip all files, and submit in the Dropbox

more...
No comment yet.
Scooped by Demetriaortega7
Scoop.it!

CIS 407 Entire Course | DeVry Online Help

http://www.devryonlinehelp.com/product/cis-407-entire-course/

Demetriaortega7's insight:

http://www.devryonlinehelp.com/product/cis-407-entire-course/

 

CIS 407 All 7 Weeks Discussions

CIS 407 All Ilabs

more...
No comment yet.
Scooped by Demetriaortega7
Scoop.it!

CIS 407 All 7 Weeks Discussions | DeVry Online Help

http://www.devryonlinehelp.com/product/cis-407-all-7-weeks-discussions/

Demetriaortega7's insight:

http://www.devryonlinehelp.com/product/cis-407-all-7-weeks-discussions/

 

Week 2 DQ Sites that Make Good Use of Input

Week 3 DQ Ethical and Legal Issues on Monitoring

Week 4 DQ Web Controls for Displaying Data

Week 5 DQ Transaction COMMIT and ROLLBACK

Week 6 DQ Web Security Issues

Week 7 DQ Error Handling

Week 8 DQ Looking Ahead

more...
No comment yet.