Esempio n. 1
0
        public Dictionary <int, string> GetItemTypesByOrderType(OrderType orderType)
        {
            var itemTypes = new Dictionary <int, string>();

            using (var connection = new SqlConnection(ConnectionString))
            {
                connection.Open();
                using (var command = connection.CreateCommand())
                {
                    command.CommandText = @"
                        SELECT IT.ItemType_ID, IT.Code
                        FROM
                            dbo.OrderTypeItemType AS OTIT INNER JOIN
                            dbo.ItemType AS IT ON OTIT.ItemType_ID = IT.ItemType_ID INNER JOIN
                            dbo.OrderType AS OT ON OTIT.OrderType_ID = OT.OrderType_ID
                        WHERE OT.Code = @orderTypeCode";

                    command.CommandType = CommandType.Text;
                    command.Parameters.Add(new SqlParameter("orderTypeCode", EnumUtility.CctCodeValueOf(orderType)));

                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            itemTypes.Add(Convert.ToInt32(reader["ItemType_ID"]), Convert.ToString(reader["Code"]));
                        }
                    }
                }
            }
            return(itemTypes);
        }
Esempio n. 2
0
        public Dictionary <int, string> GetPickListItemsByPickListType(PickListType pickListType)
        {
            var pickListItems = new Dictionary <int, string>();

            using (var connection = new SqlConnection(ConnectionString))
            {
                connection.Open();
                using (var command = connection.CreateCommand())
                {
                    command.CommandText = @"
                        SELECT PLI.PickListItem_ID, PLI.Code
	                    FROM 
                            dbo.PickListItem AS PLI INNER JOIN
                            dbo.PickList AS PL ON PLI.PickList_ID = PL.PickList_ID
	                    WHERE PL.Code = @pickListCode"    ;

                    command.CommandType = CommandType.Text;
                    command.Parameters.Add(new SqlParameter("pickListCode", EnumUtility.CctCodeValueOf(pickListType)));

                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            pickListItems.Add(Convert.ToInt32(reader["PickListItem_ID"]), Convert.ToString(reader["Code"]));
                        }
                    }
                }
            }
            return(pickListItems);
        }