public clsEmployeeCollection() { Int32 Index = 0; Int32 RecordCount = 0; clsDataConnection DB = new clsDataConnection(); DB.Execute("sproc_tblEmployees_SelectAll"); RecordCount = DB.Count; while (Index < RecordCount) { //create blank employee clsEmployee AnEmployee = new clsEmployee(); // read in fields from current record AnEmployee.EmployeeNo = Convert.ToInt32(DB.DataTable.Rows[Index]["EmployeeNo"]); AnEmployee.EmployeeName = Convert.ToString(DB.DataTable.Rows[Index]["EmployeeName"]); AnEmployee.EmployeeJoinDate = Convert.ToDateTime(DB.DataTable.Rows[Index]["EmployeeJoinDate"]); AnEmployee.EmployeeRole = Convert.ToString(DB.DataTable.Rows[Index]["EmployeeRole"]); AnEmployee.EmployeeSalary = Convert.ToString(DB.DataTable.Rows[Index]["EmployeeSalary"]); AnEmployee.EmployeeEmail = Convert.ToString(DB.DataTable.Rows[Index]["EmployeeEmail"]); AnEmployee.EmployeeDOB = Convert.ToDateTime(DB.DataTable.Rows[Index]["EmployeeDOB"]); AnEmployee.Address = Convert.ToString(DB.DataTable.Rows[Index]["EmployeeAddress"]); //add record to private data member mEmployeesList.Add(AnEmployee); //point to next record Index++; } }
//constuctuer fr the class public clsEmployeeCollection() { //var to store the index Int32 Index = 0; // var tp stor ethe record count Int32 RecordCount = 0; //object for data connection clsDataConnection DB = new clsDataConnection(); //exercute the stored proceduer DB.Execute("sproc_tblEmployees_SelectAll"); //get the count of records RecordCount = DB.Count; //while there are records to be processed while (Index < RecordCount) { clsEmployee TestItem = new clsEmployee(); //seting the prameters TestItem.EmployeeNo = 6; TestItem.EmployeeFirstName = "Crona"; TestItem.EmployeeSurName = "Maximus;"; TestItem.EmployeeContactNo = "07364736261"; TestItem.EmployeeEmail = "*****@*****.**"; // add the item to the test list mEmployeeList.Add(TestItem); // seting the prameters TestItem.EmployeeNo = 7; TestItem.EmployeeFirstName = "Prita"; TestItem.EmployeeSurName = "Sokanji;"; TestItem.EmployeeContactNo = "07726389431"; TestItem.EmployeeEmail = "*****@*****.**"; //add the item to the test list mEmployeeList.Add(TestItem); //point at the next record Index++; } }