WordPress.com



Introduction:This document is a technical which is being used for the support and the maintenance of a computer program. Without this document it can become difficult to be to update, repair or even add in new features without this document.What is the purpose of the program?The purpose of the program is to be able to reads peoples maximum heart rate by getting there data and heart rate and to be able to put into a program that can calculate their maximum heart rate. The project is called maximum heart rate project where we need to a program to be able to calculate the heart rate of a male or female. The inputs used will be your gender if you are male using this formula (220-their age) – Resting Heart Rate =maximum heart rate; and for female this formula (212-their age) – Resting Heart Rate =maximum heart rate, what age you are and how you can login in to find your data. This is the formula that will be used to calculate the Target Heart Rate = [(Maximum Heart Rate × 0.8) + Resting Heart Rate]. The outputs will be your target heart rate and the user’s maximum heart rate. The program is designed to be able to monitor you heart weight by being able to put in the age and gender that you are so the program can be able to display your average maximum heart rate and to be able to reset the heart rate monitor. They are able to login and store there maximum heart rate.Class diagram of how the program will work:Copy of the code:Note:If any boxes in program aren’t filled in the program will stop running. Connection string always needs to be changed if USB ports are different.Login form:using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Data.SqlClient;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;namespace MHRV1{ public partial class Form1 : Form { //the line below creates something called an object //this is a copy of the Reg form class. Reg registration = new Reg(); //this line is a copy of the MHR form class MHRCalc login = new MHRCalc();//the line below the sql connection connects to the database Help help = new Help(); SqlConnection cn = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=E:\Code-325 Helen\MHRV1\MHRV1\Member.mdf;Integrated Security=True"); //this is a special type of veriable which holds inofrmation or data from the details class. Details details; List<Details> detailsList = new List<Details>(); private String username = ""; private String password = ""; public int count = 0; public Form1() { InitializeComponent(); } private void button2_Click(object sender, EventArgs e) { registration.Show(); this.Hide(); } private void button1_Click(object sender, EventArgs e) { try {//the lines below it take what is in the text boxes for username and password and puts in into username and password username = txtUsername.Text; password = txtPassword.Text; //validiadting the the input to check that the user has entered into the text boxes. if (char.IsLetter(username[0]) && char.IsLetter(password[0])) {//the line below tells the program to go to this method then run the code thats attached to it. chkLogin(); } else //if not true then display a message { MessageBox.Show("Please enter a valid input"); } } catch (Exception) { MessageBox.Show("Error, invalid input"); } } private void lblUsername_Click(object sender, EventArgs e) { } private void lblPassword_Click(object sender, EventArgs e) { } private void Form1_Load(object sender, EventArgs e) { } public void readIn() { cn.Open(); //this line opens a connection to the database so that we can read and write from Console.WriteLine("Open connection"); //this line will need to verify that the connection is opened and will write an output to the screen //this line below creates a query. This is a request to the database to do something. The select is asking the database to get something from the table in the //databasecalled MHR. The * says to get everything that is in the table. The cn is the connection to the database and also the query which is sent to the database using cn. using (SqlCommand command = new SqlCommand("SELECT * FROM MemberDetails", cn)) { SqlDataReader reader = command.ExecuteReader(); //next we create the reader which then reads the data from the database. The reader which is created from a sql class that is called SQLDataReader. //We now use the reader to be able to read the data in. We do this by making a while loop. The condition of this while loop users the readto check to see if there is //something to be read in. Whilst this is true the next piece of the data is read from the database. This will read a row of data each time it loops //the connecion the while then it checks to see if there is anything to read in from the file and while true contine loop. while (reader.Read()) //the reader will read the first collumn in the row. The command GetString will retrieve the data from the reader and passes it to the variable fullname. //this reads in the next line in the database, it starts at colum one and works it way to the final column. { string forename = reader.GetString(1); string surname = reader.GetString(2); string username = reader.GetString(3); string password = reader.GetString(4); byte age = Convert.ToByte(reader.GetInt32(5)); byte resting =Convert.ToByte(reader.GetDecimal(6)); string gender = reader.GetString(7); //When all of the data from one row is retrieved and placed into a variable, the variables are put together to form one object //(this can also be known as a zip file where we put all of the related data together). This keeps all of the related data together in one palce and allow the programm keep detailsList.Add(new Details(username, forename, surname, password, gender, age, resting)); } cn.Close(); } } public void chkLogin() {//Thos makes a call to the readin method. Then the readin method will then read data from the database/ readIn(); //this will will create a tempertapry called tempUsername. string tempUsername =""; //this line will then crrate a temp variabel known as tempPassword. string tempPassword =""; //this next line below will us a while loop where it retrieves an object that is already placed into the list (this is like a table) which is called a datalist. //the condition within the while loop uses a variable coun to be bale to count the amount or number of loops. it will then check to see if the count is equal to //or less than to the number of rows that is in the detailslist. The deatailslist uses a command called .Count where it will coutn the number of rown within the list and it will return its findings. //If the condiotns are true it will the continue the loop and if the condiotins is no longer met such as if its false the loop will then break. while ( count < detailsList.Count) //this line will retrieve the object form the list from a row which is noted by coun. Then the object is then stored into a special barriable which is valled details. //Rember that the object is king of like a zip file which contains all of the data from one row in the database. { details = detailsList.ElementAt(count); //this next line will then extract the username from the object which has been held by details and it then stores it into temUsername. tempUsername = details.getusername(); //This repeats the same process. //this line below checks to see if the usename which has been extracted from the object should match the username which has been entered into the textbox. //this will then check to see if the password also meets the extracted password. If both of these are true then the next linr will run otherwise as it goes to the else statement. tempPassword = details.getpassword(); if (tempUsername.Equals(username) && tempPassword.Equals(password)) { Program.detailsGlobal = details; //this here show the mhr form login.Show(); //this one hides the current form this.Hide(); //This one breaks the loop break; }//if they are not true then this else statement below will run. else {//if the count equals the number of rows that is in detailslit ie if there are like 10 rows and the count reaches 10 the message box will then run. //This is used to prevent the message from always apperaring untill all of the rows within the list has been checked to see if a match can be found if (count == detailsList.Count-1) {//this displays a message MessageBox.Show("You cannot login"); } } //the count in increnemented ie 1 is add each time on the loop count ++; } } private void button1_Click_1(object sender, EventArgs e) { help.Show(); this.Hide(); } }}Registration:using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Data.SqlClient;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;namespace MHRV1{ public partial class MHRCalc : Form { public byte age = 0;// letter and numbers public byte resting = 0;//decimal numbers, for the resting heart rate public byte max = 0;//numerical numbers, for the maximum heart rate public String username = ""; public String gen = "Male";//letters and numbers public byte genhr = 0;//for the gender heart rate public double target = 0; public int count = 0; SqlConnection cn = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=E:\Code-325 Helen\MHRV1\MHRV1\Member.mdf;Integrated Security=True"); Details details; List<Details> detailsList = new List<Details>(); public MHRCalc() { InitializeComponent(); } private void lblPassword_Click(object sender, EventArgs e) { } private void btnBack_Click(object sender, EventArgs e) { Form1 formBK = new Form1(); this.Hide(); formBK.Show(); } private void MHRCalc_Load(object sender, EventArgs e) { } private void lblRestingHeartRate_Click(object sender, EventArgs e) { } private void btnCalculate_Click(object sender, EventArgs e) { setup(); } private void txtOutput_TextChanged(object sender, EventArgs e) { } //this method is getting the gender of which and the resting heart rate for the set gender public void genCalc() { if (gen.Equals("Male")) { genhr = 220; } else { genhr = 212; } }//this method is getting the heart rate and age and gets you the overall resting heart rate. public void mhrCalc() { max = Convert.ToByte((genhr - age) - resting); } public void targetClac() { target = Convert.ToByte((max * 0.8) + resting); max =Convert.ToByte( max + resting); } public void display() {//this method displays the target heart rate and max heart rate in the text output box. txtOutput.Text = "Your target heart rate is:" + target.ToString() + " Your maximum heart rate is:" + max.ToString(); } public void setup() { age = Program.detailsGlobal.getage(); gen = Program.detailsGlobal.getgender(); resting = Program.detailsGlobal.getresting(); genCalc(); mhrCalc(); targetClac(); display(); } private void btnHelp_Click(object sender, EventArgs e) { } private void btnSave_Click(object sender, EventArgs e) { } } }MHR:using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Data.SqlClient;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;namespace MHRV1{ public partial class MHRCalc : Form { // Help help = new Help(); public byte age = 0; public byte resting = 0; public byte max = 0; public String username = ""; public String gen = "Male"; public byte genhr = 0; public double target = 0; public int count = 0; // SqlConnection cn = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=E:\College\Unit 325 Programming\MHRV1\MHRV1\Member.mdf;Integrated Security=True"); SqlConnection cn = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=E:\Code-325 Helen\MHRV1\MHRV1\Member.mdf;Integrated Security=True"); Details details; List<Details> detailsList = new List<Details>(); public MHRCalc() { InitializeComponent(); } private void lblPassword_Click(object sender, EventArgs e) { } private void btnBack_Click(object sender, EventArgs e) { Form1 formBK = new Form1(); this.Hide(); formBK.Show(); } private void MHRCalc_Load(object sender, EventArgs e) { } private void lblRestingHeartRate_Click(object sender, EventArgs e) { } private void btnCalculate_Click(object sender, EventArgs e) { setup(); } private void txtOutput_TextChanged(object sender, EventArgs e) { } // the method below is changing the value of genhr for if the user is male or female public void genCalc() { if (gen.Equals("Male")) { genhr = 220; } else { genhr = 212; } } public void mhrCalc() { max = Convert.ToByte((genhr - age) - resting); } public void targetClac() { target = Convert.ToByte((max * 0.8) + resting); max =Convert.ToByte( max + resting); } public void display() { txtOutput.Text = "Your target heart rate is:" + target.ToString() + " Your maximum heart rate is:" + max.ToString(); } public void setup() { age = Program.detailsGlobal.getage(); gen = Program.detailsGlobal.getgender(); resting = Program.detailsGlobal.getresting(); genCalc(); mhrCalc(); targetClac(); display(); } private void btnHelp_Click(object sender, EventArgs e) { //help.Show(); //this.Hide(); } } }Help:using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;namespace MHRV1{ public partial class Help : Form { MHRCalc heart = new MHRCalc(); public Help() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { heart.Show(); this.Hide(); } private void textBox1_TextChanged(object sender, EventArgs e) { } private void Help_Load(object sender, EventArgs e) { } }}Details:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace MHRV1{ class Details {//this code below is an attribute that is used to store values that //helps to describe this class. This class is private so only they can see it. private String username = ""; private String forename = ""; private String surname = ""; private String password = ""; private String gender = ""; private byte age = 0; private byte restingheartrate = 0; public Details(String username1, String forename1, String surname1, String password1, String gen, byte age1, byte heart) { setusername(username1); setforename(forename1); setsurname(surname1); setpassword(password1); setgender(gen); setresting(heart); setage(age1); }// The code below will set a value to the private variables above public void setusername(String unames) { username = unames; } public void setforename(String fnames) { forename = fnames; } public void setsurname(String snames) { surname = snames; } public void setpassword(String pass) { password = pass; } public void setgender(String gen) { gender = gen; } public void setresting(byte heart) { restingheartrate = heart; } public void setage(byte age1) { age = age1; } //this will get the values from the private variable. public string getforename() { return forename; } public string getsurname() { return surname; } public string getusername() { return username; } public string getpassword() { return password; } public string getgender() { return gender; } public byte getage() { return age; } public byte getresting() { return restingheartrate; } }}Program:using System;using System.Collections.Generic;using System.Linq;using System.Threading.Tasks;using System.Windows.Forms;namespace MHRV1{ static class Program { static public Details detailsGlobal; /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } }}Review:What is quality?Quality is how the program work wells in all areas and what it offers to the user of who uses the software. Quality must cover the following usability which is how easy the software is to use. The efficiency of the software of how it uses the resources given such as the memory and how it reads the code. The correctness where the software will produce the correct result all the time on how well it does this. The functionality of the software of how well it functions overall where all of the features work the way there meant to. The dependability of it where does the software work properly all the time when you use it. The security of the software of how well the software keeps the data secure all of the time. The reliability of the software of how it is easy to read the code to correct any mistakes, to be able to add new features as well as make adjustments with no problem. The structure of the software of how well the code has been structured in the program of how well it can break up the code using different methods to make the code work how it meant to do.Program demonstrate:Indentation of code and use of indentation in code layout and how this helps to improve quality and state if your program requires change or not? This is used within the coding with the program where we use open and closed brackets because it helps us to see errors so that we can correct the errors much easier.An example from my code: { username = unames; }Why are variables and methods provided with names that relate to their purpose and function within the program? These are used with the coding of the program to help make it easier for us to read the code of the program and for the programmer to be able to understand the code a lot easier.Example from my code: public String name = "";Why do we insert comments into the code to help understand it and why is it beneficial? We insert comments into the code because it helps us with making the code more readable for us by using the comments so we can understand certain parts of the code a lot easier with these comments so we don’t struggle to figure out what is does.Example from my code:// the code below is called a constructor where it starts at public then the name of a class. public void setfullname(String fnames)How is data validation performed on data entered into a program to prevent incorrect data causing incorrect results or a run-time error?Date validation is performed on data entered by using the following these presence checks, range checks, character count, check digit (modulus number), format checks and the use of a lookup table for defined values.Presence checks is where it checks to see if a critical box or text box is not left blank and that the box has then been filled in. Range checks is the value that falls between certain numbers such as the use of a component called numericup and down which will input a number into a specific range.Character count is where it counts the numbers of the character of the input value so it checks that it is the right amount. E.g. this is used for things such as pin numbers.Check digit (modulus number): This type of check is mainly used with numbers where an extra check digit has been calculated form the numbers which are to be enter and then added to the end. The numbers that are put in are then checked at any stage by recalculating the check digit from all of the other numbers and seeing if the numbers matches the one that has been entered.Format check: This type of check checks the format of a value so if its lower case i.e. toLower.Use of a lookup table for defined values: This looks up the acceptable values within a table such as checking to see if the values required for a column are in a table in a database.The importance of trapping errors in a program: Trapping errors in a program means that we are able to identify what certain errors that are within the program so we can receive the problem and be able to fix it straight away. Being able to trap errors helps programmer to be to understand multiple errors with the program so it gives them a better understanding of error so that the programmer is able to fix it.The use of try/catch and finally in error trapping: Try and catch are used as a block where they are two different keywords “try” and “catch” which handles the exceptions due to coding or data during the programs execution. The try block is a piece of code were exceptions occur and the catch block is the piece of code which catches and then handles the try block exceptions. The finally in error trapping is used within try and catch blocks optionally where it guarantees the execution of any code which needs to be executed before you exit the try block so it will mainly clean up any resources which are allocated within a try block.How are screen prompts used to be able to provide information to a user about the actions that can be taken after an error? These are used when someone puts an invalid input into a program such as a sign up program where they put in the wrong information into e.g. entering there password into the email section, it will display an error message showing what the error is so that the user knows and corrects the mistake so the user put in the correct information so that an error doesn’t display again.Test log:Tester: Paul JonesTest date: Test No.TestTest DataExpectedActualScreen shot with comments1Start the program NoneLoads start screenLoads2Can you change to registration screen when clicking register?NoneRegistration screen loadsLoads3Can you click register with details enteredFull name: david banesUsername: davidPassword: banesGender: MaleAge: 35RHR: 56Registers to database Registers to database4On Registration can you go back to login screenGoes back to login screenGoes to login screen5Can you login in with incorrect detailsCan’t login in Doesn’t let you login6Can you login in with information registered Username: davidPassword: banesLogin successfulLogin you in7Does it change to the MHR screen Switches to MHR screen Changes screen 8Can go back when you click back on MHRSwitches screenGoes back to MHR9Do results come through when you put in your heart rateHeart rate: 45Calculates your heart rate and saves it.Calculates heart rate10Click save on MHR save the resultsSaves the resultsSaves the results11Click help on login screen goes to a help screenGoes to the help screenGoes to help screen12Click back on help screen goes back to MHR Goes back to HMR screenGoes to MHR screen13Reg screen: When changing details will it update when clicking update Full name: Jack SmithUsername: Smith1234Password: smithGender: MaleAge: 24Updates user details and changes them in the databaseUpdates details14Login with not informationCan’t login Can’t loginTest analysis:Test 1: This test was to see if the program will start as it’s meant to which it does this.Test 2: This tests was to see if you could switch to the registration screen which it does this.Test 3: This test was to see if you could register with information put in which it does this.Test 4: This test was to see if you could go back to the login screen from the registration screen which it does this.Test 5: This test was to see if you could login in with incorrect information which it does this.Test 6: This test was to see if you can login in with the correct information which it does this.Test 7: This test was to see if it changes to the MHR screen which it does this.Test 8: This test was to make sure you could go back to the previous screen which it does this.Test 9: This test was to see if results come through when you enter your resting heart rate which it does this.Test 10: This test was to see if the results saved which it does this.Test 11: This test was too see if you could go to the help screen form the login screen which it does this.Test 12: This test was to make sure that the back button worked on the help screen which it does this.Test 13: This test was to make sure that you could update your information on the registration screen which it does this.Help:These are used to help the user “try, catch, message boxes”Within the program I used a “try” which is used to trap any errors that happen when the user put in data. The “catch” is used to catch the error that happens so that it doesn’t display another problems with the coding then displays a message. The “message box” is used to display a message to the user that data was invalid so they know to enter correct information. ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download