/// <summary> /// gets all of the items from the database and puts them into an observablecollection /// </summary> /// <returns>the colection of items</returns> public ObservableCollection <clsItem> GetItems() { try { Items.Clear(); int iRet = 0; DataSet ds = new DataSet(); try { ds = data.ExecuteSQLStatement(SQL.GetItems(), ref iRet); } catch (Exception ex) { throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + "." + MethodInfo.GetCurrentMethod().Name + " -> " + ex.Message); } for (int i = 0; i < iRet; i++) { item = new clsItem(); item.Code = ds.Tables[0].Rows[i][0].ToString(); item.Desc = ds.Tables[0].Rows[i][1].ToString(); item.Cost = ds.Tables[0].Rows[i][2].ToString(); Items.Add(item); } return(Items); } catch (Exception ex) { throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + "." + MethodInfo.GetCurrentMethod().Name + " -> " + ex.Message); } }
public ObservableCollection <clsItem> GetItems() { DataSet ds = new DataSet(); ObservableCollection <clsItem> Items = new ObservableCollection <clsItem>(); ds = SQLCalls.GetItems(); //loop through ds //create new item //add to item to Items return(Items); }