CHAPTER 21 ADO.NET PART I: THE CONNECTED LAYER
userDone = true;
break;
default:
Console.WriteLine("Bad data!
break;
}
} while (!userDone);
Try again");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
invDAL.CloseConnection();
}
}
Implementing the ShowInstructions() Method
The ShowInstructions() method does what you would expect, as seen here:
private static void ShowInstructions()
{
Console.WriteLine("I: Inserts a new car.");
Console.WriteLine("U: Updates an existing car.");
Console.WriteLine("D: Deletes an existing car.");
Console.WriteLine("L: Lists current inventory.");
Console.WriteLine("S: Shows these instructions.");
Console.WriteLine("P: Looks up pet name.");
Console.WriteLine("Q: Quits program.");
}
Implementing the ListInventory() Method
You could implement the ListInventory() method in either of two ways, based on how you constructed
your data access library. Recall that the GetAllInventoryAsDataTable() method of InventoryDAL returns
a DataTable object. You could implement this approach like this:
private static void ListInventory(InventoryDAL invDAL)
{
// Get the list of inventory.
DataTable dt = invDAL.GetAllInventoryAsDataTable();
}
// Pass DataTable to helper function to display.
DisplayTable(dt);
The DisplayTable() helper method displays the table data using the Rows and Columns properties of
the incoming DataTable (again, you will learn the full details of the DataTable object the next chapter, so
don’t fret over the details):
849