void Add() { //create instance of employee book clsEmployeeCollection EmployeeBook = new clsEmployeeCollection(); //vlidate data in form //Valid(string employeeAddress, string employeeContactNumber, string employeeDOB, string employeeEmail, string employeeJoinDate, string employeeName, string employeeRole, string employeeSalary) String Error = EmployeeBook.ThisEmployee.Valid(txtEmployeeAddress.Text, txtEmployeeContactNo.Text, txtEmployeeDOB.Text, txtEmployeeEmail.Text, txtEmployeeJoinDate.Text, txtEmployeeName.Text, txtEmployeeRole.Text, txtEmployeeSalary.Text); //if data is OK then add to objext if (Error == " ") { //get data entered by user EmployeeBook.ThisEmployee.Address = txtEmployeeAddress.Text; EmployeeBook.ThisEmployee.EmployeeContactNumber = txtEmployeeContactNo.Text; EmployeeBook.ThisEmployee.EmployeeDOB = Convert.ToDateTime(txtEmployeeDOB.Text); EmployeeBook.ThisEmployee.EmployeeEmail = txtEmployeeEmail.Text; EmployeeBook.ThisEmployee.EmployeeJoinDate = Convert.ToDateTime(txtEmployeeContactNo.Text); //EmployeeBook.ThisEmployee.EmployeeContactNo = txtEmployeeContactNo.Text; EmployeeBook.ThisEmployee.EmployeeName = txtEmployeeName.Text; EmployeeBook.ThisEmployee.EmployeeRole = txtEmployeeRole.Text; EmployeeBook.ThisEmployee.EmployeeSalary = txtEmployeeSalary.Text; //add record EmployeeBook.Add(); } else { lblError.Text = "There was an error with the data entered" + Error; } }
public void DeleteMethodOK() { //create an instance of the class we want to create clsEmployeeCollection AllEmployees = new clsEmployeeCollection(); //create the item of test data ClsEmployee TestEmployee = new ClsEmployee(); //var to store the primary key Int32 PrimaryKey = 117; //set its properties TestEmployee.Emp_Name = "Jake Wills"; TestEmployee.Job_Name = "Supporter"; TestEmployee.Manager_ID = 2; TestEmployee.Hire_Date = DateTime.Now.Date; TestEmployee.Salary = 22000; TestEmployee.Dep_ID = 3; TestEmployee.Active = true; //set ThisAddress to the test data AllEmployees.ThisEmployee = TestEmployee; //add the record PrimaryKey = AllEmployees.Add(); //set the primary key of the test data TestEmployee.Emp_ID = PrimaryKey; //find the record AllEmployees.ThisEmployee.Find(PrimaryKey); //delete the record AllEmployees.Delete(); //now find the record Boolean Found = AllEmployees.ThisEmployee.Find(PrimaryKey); //test to see that the record was not found Assert.IsFalse(Found); }
void Add() { //create an instance of the address book clsEmployeeCollection EmployeeBook = new clsEmployeeCollection(); //validate the data on the web form String Error = EmployeeBook.ThisEmployee.Valid(txtfirstname.Text, txtlastname.Text, txtaddress.Text, txtpostcode.Text, txtdatejoined.Text, txtemail.Text, txtphone.Text); //if the data is OK then add it to the object if (Error == "") { //get the data entered by the user EmployeeBook.ThisEmployee.FirstName = txtfirstname.Text; EmployeeBook.ThisEmployee.LastName = txtlastname.Text; EmployeeBook.ThisEmployee.PostCode = txtpostcode.Text; EmployeeBook.ThisEmployee.Address = txtaddress.Text; EmployeeBook.ThisEmployee.Active = Active.Checked; EmployeeBook.ThisEmployee.EmailAddress = txtemail.Text; EmployeeBook.ThisEmployee.DateJoined = Convert.ToDateTime(txtdatejoined.Text); EmployeeBook.ThisEmployee.PhoneNumber = txtphone.Text; //add the record EmployeeBook.Add(); //all done so redirect back to the main page Response.Redirect("HomePage.aspx"); } else { //report an error lblerror.Text = "There were problems with the data entered " + Error; } }
public void ReportByEmployeeNameTestDataFound() { //create an instance of the filtered data clsEmployeeCollection FilteredEmployees = new clsEmployeeCollection(); //var to store outcome Boolean OK = true; //apply a Name that doesn't exist FilteredEmployees.ReportByEmployeeName("Thomas Wilson"); //check that the correct number of records are found if (FilteredEmployees.Count == 3) { //check that the first record is ID 1 if (FilteredEmployees.EmployeeList[0].Emp_ID != 1) { OK = false; } //check that the first record is ID 67 if (FilteredEmployees.EmployeeList[1].Emp_ID != 67) { OK = false; } //check that the first record is ID 106 if (FilteredEmployees.EmployeeList[2].Emp_ID != 106) { OK = false; } } else { OK = false; } //test to see that there are no records Assert.IsTrue(OK); }
public void EmployeeListOK() { //create instance of class clsEmployeeCollection AllEmployees = new clsEmployeeCollection(); //create some test data to assign to property //in this case data needs to be list of objects List <clsEmployee> TestList = new List <clsEmployee>(); // add new item to list //create item of test data clsEmployee TestItem = new clsEmployee(); //set properties TestItem.EmployeeNo = 1; TestItem.EmployeeName = "Vinay Kumar"; TestItem.Address = "golden mile"; TestItem.EmployeeRole = "Sales"; TestItem.EmployeeJoinDate = Convert.ToDateTime("12/04/2018"); TestItem.EmployeeDOB = Convert.ToDateTime("19/09/1985"); TestItem.EmployeeEmail = "*****@*****.**"; TestItem.EmployeeSalary = "10"; TestItem.EmployeeContactNumber = "554"; //add item to test list TestList.Add(TestItem); //asign data to property AllEmployees.EmployeesList = TestList; //test to see two values are the same Assert.AreEqual(AllEmployees.EmployeesList, TestList); }
public void AddMethodOK() { //create instance of class we want to create clsEmployeeCollection AllEmployees = new clsEmployeeCollection(); //create item of test data clsEmployee TestItem = new clsEmployee(); //var to store primary key Int32 PrimaryKey = 0; //set properties TestItem.Address = "london road"; TestItem.EmployeeContactNumber = "07777777880"; TestItem.EmployeeDOB = Convert.ToDateTime("12/01/1997"); TestItem.EmployeeEmail = "*****@*****.**"; TestItem.EmployeeJoinDate = Convert.ToDateTime("11/04/2018"); TestItem.EmployeeName = "Sandeep"; TestItem.EmployeeNo = 1; TestItem.EmployeeRole = "Accountant"; TestItem.EmployeeSalary = "1000"; //set ThisAddress to test data AllEmployees.ThisEmployee = TestItem; //add record PrimaryKey = AllEmployees.Add(); //set primary key of test data TestItem.EmployeeNo = PrimaryKey; //find record AllEmployees.ThisEmployee.Find(PrimaryKey); //test to see two values are same Assert.AreEqual(AllEmployees.ThisEmployee, TestItem); }
public void ListandCountOK() { //create an instance of the class we want to create clsEmployeeCollection Employees = new clsEmployeeCollection(); //create some test data to assign to the property //in this case the data will be a list of objects List <clsEmployee> TestList = new List <clsEmployee>(); //add an item to the list //create the item of test data clsEmployee TestEmployee = new clsEmployee(); //set its properties TestEmployee.Active = true; TestEmployee.EmployeeNo = 4375; TestEmployee.FirstName = "John"; TestEmployee.LastName = "Make"; TestEmployee.Address = " 11 donald Road"; TestEmployee.DateJoined = DateTime.Now.Date; TestEmployee.PostCode = " KT6 8RJ"; TestEmployee.EmailAddress = " [email protected]"; TestEmployee.PostCode = "07838774833"; //add the item to the test list TestList.Add(TestEmployee); //assign the data to the property Employees.EmployeeList = TestList; //test to see that the two values are the same Assert.AreEqual(Employees.EmployeeList, TestList); }
public void ListAndCountOK() { //create an instance of the class we want to create clsEmployeeCollection AllEmployee = new clsEmployeeCollection(); //create some test data to assign to the property //in this case the data needs to be a list of objects List <ClsEmployee> TestList = new List <ClsEmployee>(); //add an item to the list //create the item of test data ClsEmployee TestEmployee = new ClsEmployee(); //set its properties TestEmployee.Emp_ID = 113; TestEmployee.Emp_Name = "Jake Wills"; TestEmployee.Job_Name = "Supporter"; TestEmployee.Manager_ID = 2; TestEmployee.Hire_Date = DateTime.Now.Date; TestEmployee.Salary = 22000; TestEmployee.Dep_ID = 3; TestEmployee.Active = true; //add the item to the test list TestList.Add(TestEmployee); //assign the data to the property AllEmployee.EmployeeList = TestList; //test to see that the two values are the same Assert.AreEqual(AllEmployee.Count, TestList.Count); }
public void AddMethodOK() { //create an instance of the class we want to create clsEmployeeCollection AllEmployee = new clsEmployeeCollection(); //create the item of test data ClsEmployee TestEmployee = new ClsEmployee(); //var to store the primary key Int32 PrimaryKey = 119; //set its properties TestEmployee.Emp_Name = "Jake Wills"; TestEmployee.Job_Name = "Supporter"; TestEmployee.Manager_ID = 2; TestEmployee.Hire_Date = DateTime.Now.Date; TestEmployee.Salary = 22000; TestEmployee.Dep_ID = 3; TestEmployee.Active = true; //set ThisEmployee to the test data AllEmployee.ThisEmployee = TestEmployee; //add the record AllEmployee.Add(); //set the primary key of the test data //find the record AllEmployee.ThisEmployee.Find(PrimaryKey); //test to see that the two values are the same Assert.AreEqual(AllEmployee.ThisEmployee, TestEmployee); }
public void InstanceOK() { //creat a instance of the class we want to create clsEmployeeCollection AllEmployees = new clsEmployeeCollection(); //test to see that it exists Assert.IsNotNull(AllEmployees); }
void DisplayEmployees() { clsEmployeeCollection HR = new clsEmployeeCollection(); //set the name of the primary key lstHR.DataSource = HR.EmployeesList; lstHR.DataValueField = "EmployeeNo"; lstHR.DataTextField = "EmployeeName"; lstHR.DataBind(); }
//event handler for the apply button protected void btnApply_Click(object sender, EventArgs e) { clsEmployeeCollection employees = new clsEmployeeCollection(); employees.ReportByEmployeeName(txtName.Text); lstempoyees.DataSource = employees.EmployeeList; lstempoyees.DataValueField = "emp_ID"; lstempoyees.DataTextField = "emp_Name"; lstempoyees.DataBind(); }
void DeleteEmployee() { //function to deleate selected record //create an new instance of employee clsEmployeeCollection EmployeeList = new clsEmployeeCollection(); //find the recor to deleate EmployeeList.ThisEmployee.Find(EmployeeNo); //DELEATE YJE RECORD EmployeeList.Delete(); }
public void ReportByEmployeeNameNoneFound() { //create an instance of the filtered data clsEmployeeCollection FilteredEmployees = new clsEmployeeCollection(); //apply a post code that doesn't exist string test = "ffqobe"; FilteredEmployees.ReportByEmployeeName(test); //test to see that there are no records Assert.AreEqual(0, FilteredEmployees.Count); }
public void CountPropertyOK() { //create an instance of the class we want to create clsEmployeeCollection AllEmployee = new clsEmployeeCollection(); //create some test data to assign to the property Int32 SomeCount = 110; //assign the data to the property AllEmployee.Count = SomeCount; //test to see that the two values are the same Assert.AreNotEqual(AllEmployee.Count, SomeCount); }
public void ReportByEmployeeNameMethodOK() { //create an instance of the class containing unfiltered results clsEmployeeCollection AllEmpoyees = new clsEmployeeCollection(); //create an instance of the filtered data clsEmployeeCollection FilteredEmployees = new clsEmployeeCollection(); //apply a blank string (should return all records); FilteredEmployees.ReportByEmployeeName(""); //test to see that the two values are the same Assert.AreEqual(FilteredEmployees.Count, AllEmpoyees.Count); }
void DeleteEmployee() { //function to delete the selected record //create a new instance of the address book clsEmployeeCollection EmployeeBook = new clsEmployeeCollection(); //find the record to delete EmployeeBook.ThisEmployee.Find(emp_ID); //delete the record EmployeeBook.Delete(); }
void DisplayNames() { //create an instance of the Employee Collection clsEmployeeCollection Names = new clsEmployeeCollection(); //set the data source to the list of names in the collection lstempoyees.DataSource = Names.EmployeeList; //set the name of the primary key lstempoyees.DataValueField = "emp_ID"; //set the data field to display lstempoyees.DataTextField = "emp_Name"; //bind the data to the list lstempoyees.DataBind(); }
void DisplayEmployee() { clsEmployeeCollection EmployeeList = new clsEmployeeCollection(); EmployeeList.ThisEmployee.Find(emp_ID); //display the data txtemp_ID.Text = EmployeeList.ThisEmployee.Emp_ID.ToString(); txtemp_Name.Text = EmployeeList.ThisEmployee.Emp_Name; txtjob_Name.Text = EmployeeList.ThisEmployee.Job_Name; txtmanager_ID.Text = EmployeeList.ThisEmployee.Manager_ID.ToString(); txthire_Date.Text = EmployeeList.ThisEmployee.Hire_Date.ToString(); txtsalary.Text = EmployeeList.ThisEmployee.Salary.ToString(); txtdep_ID.Text = EmployeeList.ThisEmployee.Dep_ID.ToString(); chkActive.Checked = EmployeeList.ThisEmployee.Active; }
protected void btnOK_Click(object sender, EventArgs e) { ClsEmployee AnEmployee = new ClsEmployee(); string emp_Name = txtemp_Name.Text; string job_Name = txtjob_Name.Text; string dep_ID = txtdep_ID.Text; string hire_Date = txthire_Date.Text; string manager_ID = txtmanager_ID.Text; string salary = txtsalary.Text; string check = chkActive.Text; string Error = ""; Error = AnEmployee.Valid(emp_Name, job_Name, manager_ID, Convert.ToDateTime(hire_Date), salary, dep_ID, chkActive.Checked); if (Error == "") { AnEmployee.Emp_ID = emp_ID; AnEmployee.Emp_Name = emp_Name; AnEmployee.Job_Name = job_Name; AnEmployee.Manager_ID = Convert.ToInt32(manager_ID); AnEmployee.Hire_Date = Convert.ToDateTime(hire_Date); AnEmployee.Salary = Convert.ToInt32(salary); AnEmployee.Dep_ID = Convert.ToInt32(dep_ID); AnEmployee.Active = chkActive.Checked; clsEmployeeCollection EmployeeList = new clsEmployeeCollection(); if (Convert.ToInt32(emp_ID) == -1) { EmployeeList.ThisEmployee = AnEmployee; EmployeeList.Add(); } else { EmployeeList.ThisEmployee.Find(Convert.ToInt32(emp_ID)); EmployeeList.ThisEmployee = AnEmployee; EmployeeList.Update(); } Response.Redirect("DefaultEmployee.aspx"); } else { lblError.Text = Error; } }
public void ThisEmployeePropertyOK() { //create an instance of the class we want to create clsEmployeeCollection AllEmployee = new clsEmployeeCollection(); //create some test data to assign to the property ClsEmployee TestEmployee = new ClsEmployee(); //set the properties of the test object TestEmployee.Emp_ID = 113; TestEmployee.Emp_Name = "Jake Wills"; TestEmployee.Job_Name = "Supporter"; TestEmployee.Manager_ID = 2; TestEmployee.Hire_Date = DateTime.Now.Date; TestEmployee.Salary = 22000; TestEmployee.Dep_ID = 3; TestEmployee.Active = true; //assign the data to the property AllEmployee.ThisEmployee = TestEmployee; //test to see that the two values are the same Assert.AreEqual(AllEmployee.ThisEmployee, TestEmployee); }
public void UpdateMethodOK() { //create an instance of the class we want to create clsEmployeeCollection AllEmployees = new clsEmployeeCollection(); //create the item of test data ClsEmployee TestEmployee = new ClsEmployee(); //var to store the primary key Int32 PrimaryKey = 117; //set its properties TestEmployee.Emp_Name = "Jake Wills"; TestEmployee.Job_Name = "Supporter"; TestEmployee.Manager_ID = 2; TestEmployee.Hire_Date = DateTime.Now.Date; TestEmployee.Salary = 22000; TestEmployee.Dep_ID = 3; TestEmployee.Active = true; //set ThisAddress to the test data AllEmployees.ThisEmployee = TestEmployee; //add the record PrimaryKey = AllEmployees.Add(); //set the primary key of the test data TestEmployee.Emp_ID = PrimaryKey; //modify the test data TestEmployee.Emp_Name = "Jake Williams"; TestEmployee.Job_Name = "Supporter"; TestEmployee.Manager_ID = 2; TestEmployee.Hire_Date = DateTime.Now.Date; TestEmployee.Salary = 22000; TestEmployee.Dep_ID = 3; TestEmployee.Active = true; //set the record based on the new test data AllEmployees.ThisEmployee = TestEmployee; //update the record AllEmployees.Update(); //find the record AllEmployees.ThisEmployee.Find(PrimaryKey); //test to see ThisAddress matches the test data Assert.AreEqual(AllEmployees.ThisEmployee, TestEmployee); }
public void ThisEmployeePropertyOK() { //create an instance of the class we want to create clsEmployeeCollection AllEmployees = new clsEmployeeCollection(); // create some test data to asign toi the property clsEmployee TestEmployee = new clsEmployee(); TestEmployee.Active = true; TestEmployee.EmployeeNo = 4375; TestEmployee.FirstName = "John"; TestEmployee.LastName = "Make"; TestEmployee.Address = " 11 donald Road"; TestEmployee.DateJoined = DateTime.Now.Date; TestEmployee.PostCode = " KT6 8RJ"; TestEmployee.EmailAddress = " [email protected]"; TestEmployee.PostCode = "07838774833"; // asign data to this property AllEmployees.ThisEmployee = TestEmployee; // test to see f the two value are the same Assert.AreEqual(AllEmployees.ThisEmployee, TestEmployee); }
public void ThisEmployeePropertyOK() { //create instance of class we want to create clsEmployeeCollection AllEmployees = new clsEmployeeCollection(); //create some test data to assign to the property clsEmployee TestEmployee = new clsEmployee(); //set property of the test objects TestEmployee.EmployeeNo = 1; TestEmployee.EmployeeName = "Vinay Kumar"; TestEmployee.Address = "golden mile"; TestEmployee.EmployeeRole = "Sales"; TestEmployee.EmployeeJoinDate = Convert.ToDateTime("12/04/2018"); TestEmployee.EmployeeDOB = Convert.ToDateTime("19/09/1985"); TestEmployee.EmployeeEmail = "*****@*****.**"; TestEmployee.EmployeeSalary = "10"; TestEmployee.EmployeeContactNumber = "554"; //assign data to the property AllEmployees.ThisEmployee = TestEmployee; //test to see that two values are the same Assert.AreEqual(AllEmployees.ThisEmployee, TestEmployee); }
public void AddMethodOK() { clsEmployeeCollection AllEmployees = new clsEmployeeCollection(); // create the item of test data clsEmployee TestEmployee = new clsEmployee(); // var to store the primary key Int32 PrimaryKey = 0; //set its propertys TestEmployee.Active = true; TestEmployee.EmployeeNo = 4375; TestEmployee.FirstName = "John"; TestEmployee.LastName = "Make"; TestEmployee.Address = " 11 donald Road"; TestEmployee.DateJoined = DateTime.Now.Date; TestEmployee.PostCode = " KT6 8RJ"; TestEmployee.EmailAddress = " [email protected]"; TestEmployee.PostCode = "07838774833"; // set thius employee to test data AllEmployees.ThisEmployee = TestEmployee; // add the record // PrimaryKey = AllEmployees.Add(); }