//constructor for the class public clsCopyCollection() { //var for the index Int32 Index = 0; //var to store the record count Int32 RecordCount = 0; //object for data connection clsDataConnection DB = new clsDataConnection(); //execute the stored procodure DB.Execute("sproc_CopyTable_SelectAll"); //get the count of records RecordCount = DB.Count; //while there are records to process while (Index < RecordCount) { //Create a blank Customer clsCopy AnBook = new clsCopy(); AnBook.CopyBarCode = Convert.ToInt32(DB.DataTable.Rows[Index]["CopyBarCode"]); AnBook.FK_ISBN = Convert.ToInt32(DB.DataTable.Rows[Index]["FK_ISBN"]); AnBook.CopyLoanType = Convert.ToString(DB.DataTable.Rows[Index]["CopyLoanType"]); AnBook.CopyCondition = Convert.ToString(DB.DataTable.Rows[Index]["CopyCondition"]); AnBook.CopyStatus = Convert.ToString(DB.DataTable.Rows[Index]["CopyStatus"]); //add the records into a private data member mBookList.Add(AnBook); //point to the next record Index++; } }
void PopulateArray(clsDataConnection DB) { //populates array list based on the data table in the parameter DB //var for the index Int32 Index = 0; //var to store the record count. Int32 RecordCount; //get the count of records RecordCount = DB.Count; //clear the private array lsit mBookList = new List <clsCopy>(); //while there are records to process while (Index < RecordCount) { clsCopy AnBook = new clsCopy(); AnBook.CopyBarCode = Convert.ToInt32(DB.DataTable.Rows[Index]["CopyBarCode"]); AnBook.FK_ISBN = Convert.ToInt32(DB.DataTable.Rows[Index]["FK_ISBN"]); AnBook.CopyCondition = Convert.ToString(DB.DataTable.Rows[Index]["CopyCondition"]); AnBook.CopyStatus = Convert.ToString(DB.DataTable.Rows[Index]["CopyStatus"]); AnBook.CopyLoanType = Convert.ToString(DB.DataTable.Rows[Index]["CopyLoanType"]); //add the records into a private data member mBookList.Add(AnBook); //point to the next record Index++; } }