internal static ItemAttribute GetItemAttribute(string itemAttributeID) { string connectionString = ConfigurationManager.ConnectionStrings["Project1"].ToString(); string sql = "select items.description as ItemDescription, " + "itemattribute.description as ItemAttributeDescription, itemattribute.MarkupPercentage, itemattribute.MarkupFlatRate, itemattribute.ItemAttributeID" + " from Items, ItemAttribute where Items.ItemID = itemattribute.itemid and ItemAttribute.ItemAttributeID = " + itemAttributeID; ItemAttribute itemAttribute = new ItemAttribute(); using (SqlConnection myConnection = new SqlConnection(connectionString)) { myConnection.Open(); using (SqlCommand myCommand = new SqlCommand(sql, myConnection)) { using (SqlDataReader myDataReader = myCommand.ExecuteReader()) { if (myDataReader.Read()) { itemAttribute.Description = myDataReader["ItemAttributeDescription"].ToString(); itemAttribute.MarkupPertcentage = myDataReader["MarkupPercentage"].ToString(); itemAttribute.MarkupFlatRate = myDataReader["MarkupFlatRate"].ToString(); itemAttribute.ItemAttributeID = myDataReader["ItemAttributeID"].ToString(); } } } } return itemAttribute; }
internal static IEnumerable<ItemAttribute> GetItemAttributes(string itemID) { List<ItemAttribute> itemAttributes = new List<ItemAttribute>(); ItemAttribute itemAttribute = new ItemAttribute(); string connectionString = ConfigurationManager.ConnectionStrings["Project1"].ToString(); string sql = "select Description, MarkupPercentage, MarkupFlatRate,ItemAttributeID " + " from ItemAttribute where ItemID = " + itemID; using (SqlConnection myConnection = new SqlConnection(connectionString)) { myConnection.Open(); using (SqlCommand myCommand = new SqlCommand(sql, myConnection)) { using (SqlDataReader myDataReader = myCommand.ExecuteReader()) { while (myDataReader.Read()) { itemAttributes.Add(new ItemAttribute( myDataReader["Description"].ToString(), myDataReader["MarkupPercentage"].ToString(), myDataReader["MarkupFlatRate"].ToString(), myDataReader["ItemAttributeID"].ToString())); } } } } return itemAttributes; }