DataSet dataSet; if (database.ExecuteSqlCommand(sqlCommand, out dataSet, ref messageText, ref statusCode)) { String description = ""; StringBuilder displayString = new StringBuilder(); String location; if (0 == dataSet.Tables[0].Rows.Count) { description = tcDCI; displayString.AppendFormat("Quantities On Hand For: {0}{1} No On Hand quantities found.{1}", description, Environment.NewLine); } else { Int32 counter = 1; Int32 onHand; foreach (DataRow row in dataSet.Tables[0].Rows) { if (1 == counter) { String matrixAttribute; matrixAttribute = (String)row["mattrib"]; if (!String.IsNullOrWhiteSpace(matrixAttribute)) matrixAttribute = ", (" + matrixAttribute + ")"; description = ((String)row["idescrip"]).Trim() + matrixAttribute; displayString.AppendFormat("Quantities On Hand For: {0}{1}", description, Environment.NewLine); // This is a constant, so AppendLine would be appropriate displayString.AppendLine(" Location Quantity"); displayString.AppendLine(" ---------- -----------"); } counter++; location = (String)row["location"]; onHand = Convert.ToInt32(row["on_hand"]); displayString.AppendFormat(" {0,-10} {1,11:N0}{2}", location, onHand, Environment.NewLine); } } displayString.AppendFormat("{1}Quantities On Order For: {0}{1}", description, Environment.NewLine); if (0 == dataSet.Tables[1].Rows.Count) { displayString.AppendFormat(" No On Order quantities found.{0}", Environment.NewLine); } else { displayString.AppendLine(" Location PO Number Ordered Received Pending Expected Primary Vendor"); displayString.AppendLine(" ---------- ---------------- ------- -------- ------- ---------- -------------------------"); String vendor, externalPO, cExpected; Int32 onOrder, received, remained; DateTime expected; foreach (DataRow row in dataSet.Tables[1].Rows) { { location = (String)row["location"]; vendor = (String)row["vendor"]; onOrder = Convert.ToInt32(row["qty_orderd"]); received = Convert.ToInt32(row["qty_rcvd"]); remained = Convert.ToInt32(row["qty_remain"]); expected = Convert.ToDateTime(row["date_expct"]); externalPO = (String)row["externl_po"]; if (Siriusware.Library.Functions.DTSqlMinDate == expected) cExpected = ""; else cExpected = expected.ToShortDateString(); displayString.AppendFormat(" {0,-10} {1,-16} {2:N0} {3:N0} {4:N0} {5,-10} {6}{7}", location, externalPO, onOrder, received, remained, cExpected, vendor, Environment.NewLine); } } } messageText = displayString.ToString(); Logging.Log(messageText, 3); }