private static void sqlGetQuotes() { //SqlConnection connection = new SqlConnection("Data Source=fastapps04.qut.edu.au;Initial Catalog=n5499879;User ID=n5499879;Password=ohmedix"); List <_Quote> quotes = new List <_Quote>(); SqlCommand cmd = new SqlCommand("SELECT * FROM Quote", connection); try { connection.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { _Quote q = new _Quote(); q.TotalServiceTime = reader.GetInt32(1); q.PartsETA = reader.GetDateTime(3); q.IsApproved = reader.GetBoolean(4); q.PurchaseOrderID = reader.GetInt32(5); q.ServiceDescription = reader.GetString(7); q.AdditionalLabourPrice = reader.GetInt32(8); quotes.Add(q); } reader.Close(); foreach (_Quote q in quotes) { cmd.CommandText = "SELECT * FROM QuotePart qp INNER JOIN WarehouseStock whs ON qp.PartID = whs.PartID WHERE qp.QuoteID=" + q.ID; SqlDataReader r = cmd.ExecuteReader(); while (r.Read()) { _Item i = new _Item(); i.ID = r.GetInt32(1); i.Quantity = r.GetInt32(2); i.Description = r.GetString(4); i.Price = r.GetInt32(5); i.ServiceTime = r.GetInt32(7); q.AddItem(i); } r.Close(); } } finally { connection.Close(); } }
public void AddItem(_Item item) { items.AddLast(item); }