Exemplo n.º 1
0
        /// <summary>
        /// Process the trim equipment
        /// </summary>
        /// <param name="result">The trim list result</param>
        /// <param name="dataReader">The datareader</param>
        private void ProcessTrimEquipment(TrimList result, SqlDataReader dataReader)
        {
            ITrim currentTrim = null;

            while (dataReader.Read())
            {
                string thisTrimName = DataUtil.GetString(dataReader, "TrimName", String.Empty).Trim();
                if (currentTrim == null || currentTrim.Name != thisTrimName)
                {
                    int trimIndex = result.IndexOf(thisTrimName);
                    if (trimIndex >= 0)
                    {
                        currentTrim = result[trimIndex];
                        if (currentTrim.Equipment == null)
                        {
                            currentTrim.Equipment = new EquipmentList();
                        }
                    }
                    else
                    {
                        continue;
                    }
                }

                EquipmentItem ei = new EquipmentItem();
                ei.Name  = DataUtil.GetString(dataReader, "Generic").Replace("`", "'");
                ei.OnAll = DataUtil.GetBoolean(dataReader, "OnAllDers");
                currentTrim.Equipment.Add(ei);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// The trims and equipment details for a model
        /// </summary>
        /// <param name="modelId">The model id</param>
        /// <returns>The trim list</returns>
        public TrimList GetTrimListFromModelId(int modelId)
        {
            TrimList result = new TrimList();

            Sproc procedure = new Sproc("Trim_S_ByModel", DatabaseName);

            procedure.Parameters.Add("@CARModId", SqlDbType.Int).Value = modelId;
            using (SqlDataReader datareader = procedure.ExecuteReader())
            {
                if (datareader != null && datareader.HasRows)
                {
                    this.ProcessTrims(result, datareader);
                    datareader.NextResult();
                    this.ProcessTrimEquipment(result, datareader);
                }
            }

            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Process the trims
        /// </summary>
        /// <param name="result">The trim result</param>
        /// <param name="dataReader">The datareader</param>
        private void ProcessTrims(TrimList result, SqlDataReader dataReader)
        {
            ITrim currentTrim = null;

            while (dataReader.Read())
            {
                string trimName        = DataUtil.GetString(dataReader, "TrimName", String.Empty).Trim();
                string basedOnTrimName = DataUtil.GetString(dataReader, "BasedOnTrimName", null);

                currentTrim      = new Trim();
                currentTrim.Name = trimName;

                if (basedOnTrimName != null && basedOnTrimName != trimName)
                {
                    currentTrim.BasedOn = basedOnTrimName.Trim();
                }

                result.Add(currentTrim);
            }
        }