Cis 407 i lab 6 of 7

166 views
108 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
166
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Cis 407 i lab 6 of 7

  1. 1. HELPIDO.COMCLICK HERE TO GET THE SOLUTION !!!!!!!!CIS 407 A – ILAB 6 OF 7i L A B O V E R V I E WScenario/SummaryIn this weeks lab, we will create a login form, validate a user based on their login name and password,and allow them to access the system or not. We will assign a session variable to determine the level ofsecurity the user has and allow certain functions to be displayed or not displayed in the existingfrmPersonnel form depending on the assigned security level. (NOTE: In some cases the instructions forthis lab will be less specific than in earlier labs, because you are expected to apply what you have learnedin earlier weeks. Refer to the detailed instructions in previous weeks labs if you need to do so.)Instructions for Week 6 iLab: Login and Security LevelsClick on the link above to view the tutorial.Please watch this tutorial before beginning the iLab.The tutorial has audio.DeliverablesWhen you try to log in, if you use User Name = Mickey and Password = Mouse, the frmMain form shouldopen with all links visible. If you use User Name = Minnie and Password = Mouse, the frmMain formshould open with only the Salary Calculator, View Personnel, and Search options should be available.You will have a new option called Manage Users that will allow you to add new users and remove orupdate existing users. Once you have verified that it works, save your website, zip up all files, and submitin the Dropbox.Note on database connections: We are using a SQLDataSource control for the Edit employees featurewe added. You should be using the connection string stored in the web.config file for your databaseconnection for this control. Rather than creating a new connection each time, just use this connection. Ifyou change the folder where your website is (e.g., you copy each weeks work to a new location), you willneed to update the web.config. The advantage of using the database connection in the web.config is thatyou only have to set the configuration in one location.Before starting this weeks lab, make sure everything is working and that all database connections areproperly configured.i L A B S T E P SSTEP 1: Login Form (10 points)1. Open Microsoft Visual Studio.NET 2008.
  2. 2. 2. Click the ASP.NET website named PayrollSystem to open it.3. Create a new web form named frmLogin.4. Drop a login control onto the form.5. Set the properties of the login control as follows:PROPERTY VALUEDestinationPageUrl frmMain.aspxTitleTextPlease enter your UserNameand Password in order to loginto the system6. Add the CoolBizProductions, Inc. logo to the frmLogin form. Do not hylerlink the logo.7. Highlight everything in the form, then click Format, Justify, Center. Save your work.8. Go to the Solution Explorer, right-click on frmLogin, and left-click on Set As Start Page. Then runthe website to check if the web form appears correctly.Click on image to enlarge.Login Form In Browser9.Click here for text description of this image.STEP 2: Login Check (10 points)9. Create a new DataSet called dsUser. Use the table tblLogin as the database table for thisdataset. Do this in the same way you added datasets in the previous labs.10. Open the clsDataLayer and add the following function:// This function verifies a user in the tblUser tablepublic staticdsUserVerifyUser(string Database, stringUserName, stringUserPassword){// Add your comments heredsUser DS;OleDbConnectionsqlConn;OleDbDataAdaptersqlDA;// Add your comments heresqlConn = newOleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" +"Data Source=" + Database);
  3. 3. // Add your comments heresqlDA = newOleDbDataAdapter("Select SecurityLevel from tblUserLogin " +"where UserName like " + UserName + " " +"and UserPassword like " + UserPassword + "", sqlConn);// Add your comments hereDS = newdsUser();// Add your comments heresqlDA.Fill(DS.tblUserLogin);// Add your comments herereturn DS;}11. Double-click on the login control you added. Add the following code to the login controlAuthenticate event handler:// Add your comments heredsUserdsUserLogin;// Add your comments herestringSecurityLevel;// Add your comments heredsUserLogin = clsDataLayer.VerifyUser(Server.MapPath("PayrollSystem_DB.mdb"),Login1.UserName, Login1.Password);// Add your comments hereif (dsUserLogin.tblUserLogin.Count< 1){e.Authenticated = false;return;}// Add your comments hereSecurityLevel = dsUserLogin.tblUserLogin[0].SecurityLevel.ToString();// Add your comments hereswitch (SecurityLevel){case"A":// Add your comments heree.Authenticated = true;Session["SecurityLevel"] = "A";break;case"U":// Add your comments heree.Authenticated = true;Session["SecurityLevel"] = "U";break;
  4. 4. default:e.Authenticated = false;STEP 3: Test and Submit (10 points)12. Open the frmPersonnel form and add the following code to its Page_Load() function:// Add your comments hereif (Session["SecurityLevel"] == "A") {btnSubmit.Visible = true;//Add your comments here} else {btnSubmit.Visible = false;}13. Set the start page as frmLogin.aspx. Run the website. Try to log in with both User Name = Mickeyand Password = Mouse and User Name = Minnie and Password = Mouse. Any other user ID andpassword should not allow you to log in.14. When the user logs in we want to restrict what they can see and do based on their user role. Therole is stored in the database table tblUserLogin. Mickey Mouse has all privileges whereas MinnieMouse has read only privileges. We want to control the visibility of the links on the frmMain page.15. Initially we did not set the ID of any of the Link Button or Image Button controls that we used onfrmMain. In order to make our code more maintainable we will change the IDs as follows:Option Link Button ID Image Button IDAnnualSalaryCalculatorlinkbtnCalculator imgbtnCalculatorAdd NewEmployeelinkbtnNewEmployee imgbtnNewEmployeeView UserActivitylinkbtnViewUserActivity imgbtnViewUserActivityViewPersonnellinkbtnViewPersonnel imgbtnViewPersonnelSearchPersonnellinkbtnSearch imgbtnSearchEditEmployeeslinkbtnEditEmployees imgbtnEditEmployees16. Modify the main form so that the following options are turned off for nonadmin users:o Add New Employeeo View User Activityo Edit Employees17. You now have a web application that honors the role of the logged in user. We dont have a wayof managing the user roles and users in the system.
  5. 5. 18. Add a new form called frmManageUsers that will allow the user to add new users. The user willalso need to be able to view all users and modify or delete any of the users in the database. Adda main form option called Manage Users that is only accessible to admin users. Add the link andimage buttons as we have done in the past. Add the CoolBiz logo that is hyperlinked as you did inprevious assignments.o For the security level of the user, use a dropdown list control to allow the user to selectfrom A or U.o Name the controls with names that make sense.o Add code as appropriate to the code behind and clsDataLayer.19. Hints:o Make sure you reestablish your database connection if you copied the files from aprevious lab.o Update any DataSource controls you added with the new Payroll database location.o You can turn a control on or off by setting its Visible property.o You can add a data entry form for new users and a grid displaying all users all on thesame form.o To force a gridView to refresh call its DataBind method.o In order to use the Advanced SQL Generation option (allowing you to update/deleterecords) 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 inAccess.20. Test your application to make sure you are logging in with an invalid user id. Try to log in withboth Minnie and Mickey and make sure the UI adjusts by the role properly. Make sure you canutilize the Manage Users functionality to add/modify/delete and view user information. Once youhave verified that everything works, save your project, zip up all files, and submit in the Dropbox.NOTE: Make sure you include comments in the code provided where specified (where the " //Your comments here" is mentioned); also, any code you write needs to be properly commented,or else a five point deduction per item (form, class, function) will be made.Mickey Mouse (Admin)Click on image to enlarge.frmMain After Mickey LoginClick here for text description ofthis image.Minnie Mouse (User)Click on image to enlarge.frmMain After Minnie LoginClick here for text description ofthis image.frmManageUsersClick on image to enlarge.frmManageUsersClick here for text description ofthis image.

×