示例#1
0
        /// <summary>
        /// 根据产品分类id获取相关的自定义属性
        /// </summary>
        /// <param name="typeId">产品分类id</param>
        /// <returns></returns>
        public IList<Model.FieldValueInfo> GetFieldValueForPtid(int typeId)
        {
            IList<Model.FieldValueInfo> infos = new List<Model.FieldValueInfo>();

            if (typeId < 1)
            {
                return infos;
            }

            string sql = @"SELECT Id,ProductTypeId,CName,EName,Type,Description,DefaultValue
                            ,InitValue,InputModel from " + TableName + @"
                            where [type]='radio' and ProductTypeId =@TypeId or charindex(','+cast(ProductTypeId as varchar(50))+',',(select FullId from " + ProductTypeTableName
                            + @" where PT_Id=@TypeId))>0";

            SqlParameter[] parms = new SqlParameter[] { new SqlParameter("@TypeId", typeId) };

            using (SqlDataReader reader = XYECOM.Core.Data.SqlHelper.ExecuteReader(CommandType.Text, sql, parms))
            {
                while (reader.Read())
                {
                    Model.FieldValueInfo info = new Model.FieldValueInfo();
                    info.FieldId = XYECOM.Core.MyConvert.GetInt32(reader["Id"].ToString());
                    info.Field = new Model.FieldInfo();

                    info.Field.CName = reader["CName"].ToString();
                    info.Field.DefaultValue = reader["DefaultValue"].ToString();
                    info.Field.Description = reader["Description"].ToString();
                    info.Field.EName = reader["EName"].ToString();
                    info.Field.Id = info.FieldId;
                    info.Field.InitValue = reader["InitValue"].ToString();
                    info.Field.InputModel = reader["InputModel"].ToString();

                    info.Field.Type = reader["Type"].ToString();
                    info.Field.ProductTypeId = XYECOM.Core.MyConvert.GetInt32(reader["ProductTypeId"].ToString());

                    info.FieldValue = "";

                    info.ProductId = 0;
                    info.Id = 0;

                    infos.Add(info);
                }
            }
示例#2
0
        /// <summary>
        /// 根据分类属性ID获取分类属性值信息 (王振添加 2011-03-30)
        /// </summary>
        /// <param name="sinfo"></param>
        /// <returns>分类属性值信息</returns>
        public IList<Model.FieldValueInfo> GetItems(Model.SupplyInfo sinfo)
        {
            IList<Model.FieldValueInfo> infos = new List<Model.FieldValueInfo>();

            if (sinfo == null || sinfo.SortID < 1 || sinfo.InfoID < 1)
            {
                return infos;
            }

            string sql = @"select val.Id,val.ProductId,val.FieldId,val.FieldValue,fld.Id as fldId,ProductTypeId,EName,CName
                         ,Type,Description,DefaultValue,InitValue,IsRequire,InputModel from (select * from XY_FieldValue
                         where productId=" + sinfo.InfoID + ") as val inner join (select * from xy_field where producttypeId=" + sinfo.SortID + " or charindex(','+cast(producttypeid as varchar(10))+',',(select fullid from b_producttype where pt_id=" + sinfo.SortID + "))>0) as fld on fld.Id=val.fieldId";
            using (SqlDataReader reader = SqlHelper.ExecuteReader(CommandType.Text, sql, null))
            {
                while (reader.Read())
                {
                    Model.FieldValueInfo info = new Model.FieldValueInfo();
                    info.FieldId = XYECOM.Core.MyConvert.GetInt32(reader["fldId"].ToString());
                    info.Field = new Model.FieldInfo();
                    info.Field.CName = reader["CName"].ToString();
                    info.Field.DefaultValue = reader["DefaultValue"].ToString();
                    info.Field.Description = reader["Description"].ToString();
                    info.Field.EName = reader["EName"].ToString();
                    info.Field.Id = info.FieldId;
                    info.Field.InitValue = reader["InitValue"].ToString();
                    info.Field.IsRequire = XYECOM.Core.MyConvert.GetBoolean(reader["IsRequire"].ToString());
                    info.Field.Type = reader["Type"].ToString();
                    info.Field.InputModel = reader["InputModel"].ToString();
                    info.Field.ProductTypeId = XYECOM.Core.MyConvert.GetInt32(reader["ProductTypeId"].ToString());
                    info.FieldValue = reader["FieldValue"].ToString();

                    info.ProductId = sinfo.InfoID;
                    info.Product = sinfo;
                    info.Id = XYECOM.Core.MyConvert.GetInt32(reader["Id"].ToString()); ;

                    infos.Add(info);
                }
            }

            return infos;
        }