Hit The Order Button To Order A **Custom Paper**

>> CLICK HERE TO ORDER 100% ORIGINAL PAPERS FROM AustralianExpertWriters.com <<

31 Aug
2020

week5 ilab CIS407

Category:ACADEMICIAN

SOLUTION AT Australian Expert Writers

All files are located in the subdirectory of the project. The project should function as specified: When you press the Submitbutton in frmPersonnel, a record should be saved in the tblPersonneltable containing the FirstName, LastName, PayRate, StartDate, andEndDate that you entered. Test that the transaction will roll back byentering invalid information in one or more items, such as Hello for aStartDate. Check that client-side validation works: The ability to editemployees in a grid is working. Once you have verified that it works,save your website, zip up all files, and submit them to the Dropbox.Required SoftwareMicrosoft Visual Studio.NET Access the software at .devry.edu”>https://lab.devry.edu. Steps: 1, 2, and 3iLAB STEPSSTEP 1: Modify the clsDataLayer to Use a Two-Step Process.equella.ecollege.com/file/e606e21e-bbe0-4e00-98b0-b9191a3ad07f/26/CIS407A_W5_iLab.html#top”>Back to Top
1. Open Microsoft Visual Studio.NET.2. Click the ASP.NET project called PayrollSystem to open it.3. Open the clsDataLayer class.4. Modify the SavePersonnel() function so that instead of just doing a single SQL INSERT operation with all of the personnel data, it does an INSERT with only the FirstName and LastName, followed by an UPDATEto save the PayRate, StartDate, and EndDate into the new record. (Thistwo-step approach is not really necessary here because we are dealingwith only one table, tblPersonnel, but we are doing it to simulate acase with more complex processing requirements, in which we would needto insert or update data in more than one table or maybe even more thanone database.) Find the following existing code in the SavePersonnel() function: // Add your comments herestrSQL=”Insert into tblPersonnel “+“(FirstName, LastName, PayRate, StartDate, EndDate) values (‘”+FirstName+”‘, ‘”+LastName+”‘, “+PayRate+”, ‘”+StartDate+“‘, ‘”+EndDate+”‘)”;// Add your comments herecommand.CommandType=CommandType.Text;command.CommandText= strSQL;// Add your comments herecommand.ExecuteNonQuery();
Modify it so that it reads as follows: // Add your comments herestrSQL=”Insert into tblPersonnel “+“(FirstName, LastName) values (‘”+FirstName+”‘, ‘”+LastName+”‘)”;// Add your comments herecommand.CommandType=CommandType.Text;command.CommandText= strSQL;// Add your comments herecommand.ExecuteNonQuery();// Add your comments herestrSQL=”Update tblPersonnel “+“Set PayRate=”+PayRate+”, “+“StartDate=’”+StartDate+”‘, “+“EndDate=’”+EndDate+”‘ “+“Where ID=(Select Max(ID) From tblPersonnel)”;// Add your comments herecommand.CommandType=CommandType.Text;command.CommandText= strSQL;// Add your comments herecommand.ExecuteNonQuery();
5. Set frmMain as thestartup form and run the PayrollSystem Web application to test thechanges. When valid data values are entered for a new employee, thingsshould work exactly as they did previously. To test it, enter valid datafor a new employee in frmPersonnel and click Submit. ThefrmPersonnelVerified form should be displayed with the entered datavalues and a message that the record was saved successfully. Click theView Personnel button and check that the new personnel record was indeedsaved to the database and that all entered data values, including thePayRate, StartDate, and EndDate, were stored correctly. Close thebrowser window.Now run the PayrollSystem Web application again,but this time, enter some invalid data (a nonnumeric value) in thePayRate field to cause an error, .equella.ecollege.com/file/e606e21e-bbe0-4e00-98b0-b9191a3ad07f/26/week5_cis407Lab5Fig7.jpg” alt=””>6. Now, when you click Submit, the frmPersonnelVerified form should display a message indicating that the record was not saved:.equella.ecollege.com/file/e606e21e-bbe0-4e00-98b0-b9191a3ad07f/26/week5_cis407Lab5Fig8.jpg” alt=””>However,when you click on the View Personnel button to display the personnelrecords, you should see that an incomplete personnel record was in factcreated, with missing values for the PayRate, StartDate, and EndDatefields.This occurred because the Insert statement succeeded butthe following Update statement did not. We do not want to allow this tohappen because we end up with incomplete or incorrect data in thedatabase. If the Update statement fails, we want the Insert statement tobe rolled back, or undone, so that we end up with no record at all. Wewill fix this by adding transaction code in the next step.STEP 2: Add Transaction Code.equella.ecollege.com/file/e606e21e-bbe0-4e00-98b0-b9191a3ad07f/26/CIS407A_W5_iLab.html#top”>Back to Top
7. In the clsDataLayer.clsclass file, add code to the SavePersonnel() function to create atransaction object. Begin the transaction, commit the transaction if alldatabase operations are successful, and roll back the transaction ifany database operation fails. The following listing shows the completeSavePersonnel() function; the lines you will need to add are marked with** NEW ** in the preceding comment and are shown in bold and underlined.// This function saves the personnel datapublic static bool SavePersonnel(string Database, string FirstName, string LastName,string PayRate, string StartDate, string EndDate)bool recordSaved;// ** NEW ** Add your comments hereOleDbTransaction myTransaction = null;
try
// Add your comments hereOleDbConnection conn = new OleDbConnection(“PROVIDER=Microsoft.ACE.OLEDB.12.0;” +“Data Source=” + Database);conn.Open();OleDbCommand command = conn.CreateCommand();string strSQL;
// ** NEW ** Add your comments heremyTransaction = conn.BeginTransaction();command.Transaction = myTransaction; // Add your comments herestrSQL = “Insert into tblPersonnel ” +“(FirstName, LastName) values (‘” +FirstName + “‘, ‘” + LastName + “‘)”;
// Add your comments herecommand.CommandType = CommandType.Text;command.CommandText = strSQL;
// Add your comments herecommand.ExecuteNonQuery();
// Add your comments herestrSQL = “Update tblPersonnel ” +“Set PayRate=” + PayRate + “, ” +“StartDate=’” + StartDate + “‘, ” +“EndDate=’” + EndDate + “‘ ” +“Where ID=(Select Max(ID) From tblPersonnel)”;
// Add your comments herecommand.CommandType = CommandType.Text;command.CommandText = strSQL;
// Add your comments herecommand.ExecuteNonQuery();
// ** NEW ** Add your comments heremyTransaction.Commit();
// Add your comments hereconn.Close();recordSaved = true;
catch (Exception ex)
// ** NEW ** Add your comments heremyTransaction.Rollback();
recordSaved = false;
return recordSaved;
8. Run your Web application. First, enter valid data in all fields of frmPersonnel.When you press the Submit button in frmPersonnel, a record should besaved in the tblPersonnel table containing the FirstName, LastName,PayRate, StartDate, and EndDate. With valid data entered in all items,the successfully saved message should appear, indicating that the transaction was committed..equella.ecollege.com/file/e606e21e-bbe0-4e00-98b0-b9191a3ad07f/26/week5_cis407Lab5Fig9.jpg” alt=””>Click the View Personnel button and verify that the new record was in fact added to the database table correctly..equella.ecollege.com/file/e606e21e-bbe0-4e00-98b0-b9191a3ad07f/26/week5_cis407Lab5Fig10.jpg” alt=””>9.Now, close the browser, run the Web application again, and this time,test that the transaction will roll back after entering incorrectinformation. 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..equella.ecollege.com/file/e606e21e-bbe0-4e00-98b0-b9191a3ad07f/26/week5_cis407Lab5Fig11.jpg” alt=””>Click the View Personnel button and verify that this time, as desired, an incomplete record was not added to the database table..equella.ecollege.com/file/e606e21e-bbe0-4e00-98b0-b9191a3ad07f/26/week5_cis407Lab5Fig12.jpg” alt=””>10. You have seen how we used the try/catchblock to catch an unexpected error. You may have noticed that if youenter bad data for the dates, an exception is thrown. Go back to thevalidation code that you added in the frmPersonnel code and add atry/catch with logic to prevent an invalid date from causing a servererror.11. In the Week 3 Lab, you learned how to validatecode once the page was posted back to the server. There is somevalidation that must be done on the server because it requires serverresources such as the database. Some validation can also be done on theclient. If you can do validation on the client, it saves a round trip tothe server, which will improve performance. In this approach, we willcheck values before the page is submitted to the server for processing.Normally, there is a combination of server and client validation used ina Web application. ASP.Net includes validation controls which will useJavaScript on the client to perform validation. You will find these controls in the Validation group in the toolbox.12. Add validation controls to the frmPersonnel form as follows: For the first, last name, and pay rate, make sure each field has data in it. Use the RequiredFieldValidatorfor this task. Add the control to the right of the text box that youare validating. The location of the validator control is where the errormessage (if there is one) will appear for the control to which you linkthe validator. You will be adding one validator control for each textbox that you want to validate. Remember to set the ControlToValidate and ErrorMessageproperties on the validator control. Making this change eliminates theneed 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.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)dd$.equella.ecollege.com/file/e606e21e-bbe0-4e00-98b0-b9191a3ad07f/26/week5_cis407Lab5Fig1.png” alt=””>13. Remove the View Personnel and Cancelbuttons from the frmPersonnel form, because they will cause a Postbackand invoke the client-side editing that you just added. The user is ableto get to the View Personnel from the main form and from the personnelverification screen, so there is no need for these buttons now.14.Because you have entered data in this lab that is invalid and thosepartial records are in the database, you will need to add the ability to remove or update data. Open up frmMain and add a new main form option called Edit Employees. Add the link and image for it. This option will take the user to a new form called frmEditPersonnel..equella.ecollege.com/file/e606e21e-bbe0-4e00-98b0-b9191a3ad07f/26/week5_cis407Lab5Fig2.jpg” alt=””>15. Add the new form frmEditPersonnel. On frmEditPersonnel, add the ACIT logo at the top of the form. Add a label that says Edit Employees. Add a GridView control with an ID of grdEditPersonnel.16. You will now add a SQLDataSourceto the page. You will be using a databound grid for this form unlikethe previous grids, in which you added as unbound (in the designer).17. Add a new SQLDataSourcecontrol to the frmEditPersonnel in the Design View. This is not avisible control; that is, it will only appear in Design View, but theuser will never see it. Note: If you change the folder name or locationof your database, you will need to reconfigure the data source(right-click on the data source control and select the Configure DataSource option).18. There is a small >indicator in the Design View of the SQL Data Source control that youadded. If the configuration menu is collapsed (press it to open themenu), or there is a < with the menu displayed, from the data source menu, select Configure Data Source.19. Press the New Connection button and browse for the database.20. Press the Next button.21. When asked if you want to save the connection in the application configuration file, check the Yes check box and press Next.22. Select the tblPersonnel table.23. Select all columns (you can use the * for this).24. Press the Advanced button and check the Generate Insert, Update, and Delete option and press the OK button.25. Press the Next button.26. Press the Test Query button and make sure that you see all records in the database like the image below. If it does not, repeat the above steps to make sure that you did everything properly (and selected the correct database – if you are not sure, open the database in Windows Explorer to be sure that it is the one with data in tblPersonnel). Press the Finish button..equella.ecollege.com/file/e606e21e-bbe0-4e00-98b0-b9191a3ad07f/26/week5_cis407Lab5Fig3.jpg” alt=””>27. Click on the grid that 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!.equella.ecollege.com/file/e606e21e-bbe0-4e00-98b0-b9191a3ad07f/26/week5_cis407Lab5Fig6.jpg” alt=””>STEP 3: Test and Submit.equella.ecollege.com/file/e606e21e-bbe0-4e00-98b0-b9191a3ad07f/26/CIS407A_W5_iLab.html#top”>Back to Top
28. Once you haveverified that everything works as it is supposed to work, save yourproject, zip up all files, and submit it to the Dropbox.NOTE:Make sure you include comments in the code provided where specified(where the ” // Your comments here” is mentioned) and for any code youwrite, or else a 5-point deduction per item (form, class, function) willbe made.

Order from Australian Expert Writers
Best Australian Academic Writers

QUALITY: 100% ORIGINAL PAPERNO PLAGIARISM – CUSTOM PAPER

READ ALSO  use all available small business AssignmentTutorOnline | Good Grade Guarantee!