void PopulateArray(clsDataConnection DB) { //populates the array list based on the data table in the parameter DB //var for thje index Int32 Index = 0; //var to store the record count Int32 RecordCount; //get the count of records RecordCount = DB.Count; //clear the private array list mSaleItems = new List <clsSaleItem>(); //while there are records to process while (Index < RecordCount) { //create a blank sale clsSaleItem ASaleItem = new clsSaleItem(); //read in the fields from the current record ASaleItem.ItemID = Convert.ToInt32(DB.DataTable.Rows[Index]["ItemID"]); ASaleItem.ItemPrice = Convert.ToDecimal(DB.DataTable.Rows[Index]["ItemPrice"]); ASaleItem.Quantity = Convert.ToInt32(DB.DataTable.Rows[Index]["Quantity"]); ASaleItem.SaleID = Convert.ToInt32(DB.DataTable.Rows[Index]["SaleID"]); ASaleItem.DateAdded = Convert.ToDateTime(DB.DataTable.Rows[Index]["DateAdded"]); //add the record to the private data member mSaleItems.Add(ASaleItem); //point at the next record Index++; } }
public void FindAllSaleItems() { //re-set the connection myDB = new clsDataConnection(); //var to store the index Int32 Index = 0; //var to store the sale number of the current record Int32 ItemID; //var to flag that sale was found Boolean SaleItemFound; //execute the stored procedure myDB.Execute("sproc_tblSaleItem_SelectAll"); //get the count of records recordCount = myDB.Count; //while there are still records to process while (Index < myDB.Count) { //create an instance of the sale class clsSaleItem NewSaleItem = new clsSaleItem(); //get the ItemID from the database ItemID = Convert.ToInt32(myDB.DataTable.Rows[Index]["ItemID"]); //find the sale by invoking the find method SaleItemFound = NewSaleItem.Find(ItemID); if (SaleItemFound == true) { //add the sale to the list mSaleItems.Add(NewSaleItem); } //increment the index Index++; } }