Exemple #1
0
    public InventoryRecord[] GetInventory()
    {
        // First, get the DataTable from the database.
        InventoryDAL d = new InventoryDAL();
        d.OpenConnection(ConnString);
        DataTable dt = d.GetAllInventoryAsDataTable();
        d.CloseConnection();

        // Now make an List<T> to contain the records.
        List<InventoryRecord> records = new List<InventoryRecord>();

        // Copy data table into List<> of custom contracts.
        DataTableReader reader = dt.CreateDataReader();
        while (reader.Read())
        {
          InventoryRecord r = new InventoryRecord();
          r.ID = (int)reader["CarID"];
          r.Color = ((string)reader["Color"]);
          r.Make = ((string)reader["Make"]);
          r.PetName = ((string)reader["PetName"]);
          records.Add(r);
        }
        // Transform List<T> to array of InventoryRecord types.
        return (InventoryRecord[])records.ToArray();
    }
Exemple #2
0
    private void RefreshGrid()
    {
        InventoryDAL dal = new InventoryDAL();
        dal.OpenConnection(@"Data Source=(local)\SQLEXPRESS;" +
          "Initial Catalog=AutoLot;Integrated Security=True");
        DataTable theCars = dal.GetAllInventoryAsDataTable();
        dal.CloseConnection();

        carsGridView.DataSource = theCars;
        carsGridView.DataBind();
    }
 static void ListInventoryAsTable(InventoryDAL invDal) {
     Console.WriteLine("************* ListInventoryAsTable *********");
     DataTable dt = invDal.GetAllInventoryAsDataTable();
     DisplayTable(dt);
 }
Exemple #4
0
 private static void ListInventory(InventoryDAL invDAL)
 {
     // Get the list of inventory.
     DataTable dt = invDAL.GetAllInventoryAsDataTable();
     DisplayTable(dt);
 }